-
May 29th, 2013, 12:04 AM
#1
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
-
May 29th, 2013, 12:49 AM
#2
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.
-
May 29th, 2013, 01:23 AM
#3
Re: Compiler says there is no constructor, but it does have one.
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
-
May 29th, 2013, 04:15 AM
#4
Re: Compiler says there is no constructor, but it does have one.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|