Constructor issue

Hi,

In the small program I am writing, I have two static libraries:
1. tools. In this library, I have a Date and a Time class. In both these classes, the default constructor takes the system date/time. Date and Time classes are in a "tools" namespace.
2. source. This library contains the source files for my program. There is a Note class for writing notes with information such as time and date.

Both the Time and Date classes have been thoroughly tested and work fine. Now when I try to create a note object from this constructor:

1
2
3
4
5
6
7
8
9
Note::Note(const string& p_title, const string& p_body):
		   m_title(p_title), m_body(p_body)
{
	tools::Date systemDate;
	tools::Time systemTime;

	m_date(systemDate);
	m_time(systemTime);
}


I get this error message and I don't know why:

../Note.cpp: In constructor ‘tpro::Note::Note(const string&, const string&)’:
../Note.cpp:25:19: error: no match for call to ‘(tools::Date) (tools::Date&)’
  m_date(systemDate);
                   ^
../Note.cpp:26:19: error: no match for call to ‘(tools::Time) (tools::Time&)’
  m_time(systemTime);


It seems to me everything is there and defined.

P.S. I am working on Linux and Eclipse CDT and both static libraries have been linked properly to my executable project...

Thanks for the help!
Last edited on
By the way, here are the Note class attributes:

1
2
3
4
5
protected:
	std::string m_title; /**< The note title */
	std::string m_body; /**< The note content */
	tools::Date m_date; /**< The date at which the note was recorded. */
	tools::Time m_time; /**< The time at which the note was recorded */
You're really not showing enough content. For example what is m_date()?

Hello jib,

Here some additional information, please let me know if you need more:

1. Date constructors:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Date::Date()
{
	time_t rawTime = time(NULL); // using the "ctime" header here
	struct tm* timeInfo = localtime(&rawTime);

	m_year = timeInfo->tm_year + 1900;
	m_month = timeInfo->tm_mon + 1;
	m_day = timeInfo->tm_mday;
}

// and:

Date::Date(int p_year, int p_month, int p_day): m_year(p_year), m_month(p_month), m_day(p_day)
{
}


Note: the "Time" class constructors look very much like these...

2. The main (seperate project):

This works with a classic four-parameters constructor:

1
2
3
4
5
6
7
8
int main(void)
{
	tools::Date date(1988,1,22);
	tools::Time time;
	Note note("asdf", "asdf", date, time);

	return 0;
}


This does not with the above constructor (produces the error mentioned above):

1
2
3
4
5
6
int main(void)
{
	Note note("asdf", "asdf";

	return 0;
}


Hope this helps... It seems like a constructor syntax error of some sort for with other constructors, everything compiles fine, but I can't find it!

Thanks
m_date(systemDate); You are trying to invoke operator()here. Is that what you want?
MiiNiPaa!

You're right, this is not what I want to do... I just changed to m_date = systemDate and everything compiles.

May be I should take a break...

Thanks for your assistance.
Topic archived. No new replies allowed.