Jump to content
  • Advertisement


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


Undefined class

This topic is 5724 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

Hi Im having problem with classes that isent defined. Im having classes that are using eachother. So therefore I need to define them in the top of the file. What am I doing wrong? class cTexture;//inheritance from cEngine class cGraphic;//inheritance from cEngine class cEngine;//BaseClass struct sTexture; class cEngine {...}; class cTexture : public cEngine {...}; class cGraphic: public cEngine {...}; error C2079: ''Graphic'' uses undefined class ''cGraphic'' error C2079: ''Texture'' uses undefined class ''cTexture''
Leadorn- Sweden
E-Mail HomePage

Share this post

Link to post
Share on other sites
Why are you using predefined classes? In the example you gave us, just doing it normally wo;uld be fine.

Contact Me
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)

Share this post

Link to post
Share on other sites
When you define classes you are defining a new type for c++. Part of defining it correctly is letting the compiler know the size of the type, ie how much memory it will take up. To do this correctly all the sizes of members of the class have to be able to be seen. Built in types are fine but other user defined types have to be included before the new type.

If they are pointers or references you can get away with forward declarations as the sizes of pointers and references doesn't change with type and is known by the compiler.

class cTexture

class shape {
cTexture* pTexture_;

If a class is being derived it also has to be able to see the complete definition of the base class


#include "base.h"

class derived : public base {

This means you can't ever have one class dervied from another which is derived from the first etc. The size of the base class has to be well defined.

So if you think all this through in your headers you should be fine. I'll give you a hint though. Split them up into seperate headers for each class first, it'll make it easier.

[edited by - petewood on January 18, 2003 12:01:10 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!