I am trying to call constructor but it is not working. Code is something like this:
// Event.h
class Event
{
private:
int Time;
int Date;
public:
Event();
Event(int t, int d)
}
// Event.cpp
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…………..
This
requires that your
Eventclass have anoperator()(something, somethingElse), which it doesn’t have.somethingandsomethingElsewould correspond to the types ofinputTimeandinputDaterespectively, which are not specified in your question.Presumably you want to construct an
Eventusing the two argument constructor, which you can do like this:Since the error also mentions types
TimeandDate, you probably need to add a constructor that takes const references to those types, unless they can be implicitly converted toint.