Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

supagu

wtf? initializer specified for non-virtual method?

This topic is 5247 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what does this mean ObjMgr.h:34: error: initializer specified for non-virtual method `Obj* Obj::Create()'' this is my class: class Obj { public: Obj* Create() = 0; protected: }; i should be able to use Obj as an interface to return a pointer of type Obj? or is that my problem? i cant return a pointer because its abstract class?

Share this post


Link to post
Share on other sites
Advertisement
you can't say = 0 after a function in a definiton unless it's a virtual function (the = 0 means "pure virtual function" which by definition must be virtual...):

this will work:

class Obj
{
public:
virtual Obj* Create() = 0;

protected:

};


though normally you don't call a create method unless it's a singleton class. if it's not a singleton class just use a constructor:


class Obj
{
public:
Obj();

protected:

};


-me


[edited by - Palidine on February 7, 2004 12:20:20 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!