Reputation: 91
I am trying to call constructor but it is not working. Code is something like this:
class Event
{
private:
int Time;
int Date;
public:
Event();
Event(int t, int d)
}
Event::Event(){}
Event::Event(int time, int date){
Time=time;
Date=date;
}
//Now in another .cpp file I am trying to call constructor something like this:
Event eve;
eve(inputTime,inputDate); // inputTime and inputDate are inputs 4m user.
//Error is: no match for call to â(Event) (Time&, Date&)â
Any suggestions..............
Upvotes: 0
Views: 93
Reputation: 227370
This
eve(inputTime,inputDate);
requires that your Event
class have an operator()(something, somethingElse)
, which it doesn't have. something
and somethingElse
would correspond to the types of inputTime
and inputDate
respectively, which are not specified in your question.
Presumably you want to construct an Event
using the two argument constructor, which you can do like this:
Event eve(inputTime,inputDate);
Since the error also mentions types Time
and Date
, you probably need to add a constructor that takes const references to those types, unless they can be implicitly converted to int
.
Upvotes: 5