Compiler says there is no constructor, but it does have one.
Code:
activity = new Idle(this, NULL);
class Idle : public Activity
{
private:
float mTimeInIdle;
public:
Idle() : mTimeInIdle(0) { }
Idle(Objects *actor, Goods *target) : Activity(actor, target)
{
}
Error 1 error C2514: 'Idle' : class has no constructors d:\jacky\documents\visual studio 2010\projects\perfectsim\perfectsim\perfectsim\Objects\Objects.h 43 1 PerfectSim
The activity = new Idle(this, NULL) line is located inside the Objects::Objects(...) constructor.
Would it be caused by some cyclic dependencies? How do I go about resolving it?
Thanks
Jack
Re: Compiler says there is no constructor, but it does have one.
You need to place semicolons ' ; ' after your curly brackets ' { } ' inside your Idle class.
Re: Compiler says there is no constructor, but it does have one.
Quote:
Originally Posted by
FrOzeN89
You need to place semicolons ' ; ' after your curly brackets ' { } ' inside your Idle class.
Nope.
It is most likely that the compiler does not know of the Idle class as it is defined after its first use in line 1. Moving the first line after the class definition should solve this issue.
HTH,
Richard
Re: Compiler says there is no constructor, but it does have one.
Quote:
Originally Posted by
lucky6969b
Code:
activity = new Idle(this, NULL);
class Idle : public Activity
{
private:
float mTimeInIdle;
public:
Idle() : mTimeInIdle(0) { }
Idle(Objects *actor, Goods *target) : Activity(actor, target)
{
}
Error 1 error C2514: 'Idle' : class has no constructors d:\jacky\documents\visual studio 2010\projects\perfectsim\perfectsim\perfectsim\Objects\Objects.h 43 1 PerfectSim
The activity = new Idle(this, NULL) line is located inside the Objects::Objects(...) constructor.
Would it be caused by some cyclic dependencies? How do I go about resolving it?
Thanks
Jack
How can we answer you if you post incomplete code, with only descriptions of what you may or may not have done in some other module?
If you get a compiler error, it is imperative you post the smallest example that properly generates the error without anyone having to remove or add lines to get the same or similar error. If I took the code you posted and tried to compile it, of course there will be errors all over the place.
Regards,
Paul McKenzie