Jump to content
  • Advertisement

Archived

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

Roof Top Pew Wee

Problem with headers and classes.

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

I am trying to create my own GUI with my own line and square classes that plot themselves with functions. Everything was fine and I have the objects put in a header called ddstructs.h . In another file, called LegendsGUI.h, I have created some objects which are child classes of the base shapes. Here's the code: //ddstructs.h class line : public graphicsObject // holds ddsd and basic stuff { // left out because everything here works fine }; // end of line class class square {public: // left stuff out. Again everthing is fine square(bla bla bla) // constructor works fine void drawSquare()// again works fine }; // end of ddstructs.h Now the problem: // legendsGUI.h // I made this class just to test inheritance between header // files #include "ddstructs.h" class superSquare : public square { public: superSquare(){}; superSquare(int top, int bottom, int left, int right, int width, int r, int g, int b, DDSURFACEDESC2* DDsd) { square(top, bottom, left, right, width, r, g, b, DDsd); }; void drawSuper() { drawSquare(); } }; My program includes the "LegendsGUI.h" file which includes the "ddstructs.h" file. In my main program, I can create a square or line and everything works fine, but when I try to create a superSquare, I get no errors, but neither my drawSuper() nor my superSquare::drawSquare() functions will work. Any ideas as to why it won't work? I am pretty sure it has to do with the inheritance being between two headers, but I can't figure out what. My EMail is VChelaru@hotmail.com if it is a complicated explanation. Thanks in advance. --Vic-- Edited by - Roof Top Pew Wee on July 31, 2001 2:33:36 PM Edited by - Roof Top Pew Wee on July 31, 2001 2:36:14 PM

Share this post


Link to post
Share on other sites
Advertisement
In your superSquare constructor, don't manually call the constructor for Square, instead do it with an initializer list:

superSquare(int top, int bottom, int left, int right, int width, int r, int g, int b, DSURFACEDESC2* DDsd) : square(top, bottom, left, right, width, r, g, b, DDsd)
{

};


- Matt



Edited by - 3dModelMan on July 31, 2001 3:10:40 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!