Jump to content
  • Advertisement
Sign in to follow this  

Inheritance problem?

This topic is 4830 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 have this little problem, I'm not sure if I've got syntax wrong or what but this is really confusing me and I can't spot the problem. I have these 2 classes:
#ifndef GUI_OBJECT_H
#define GUI_OBJECT_H

class GUIObject {
        int x, y, width, height;
        virtual void draw() = 0;
        virtual void resize(int width, int height) {
            this->width = width;
            this->height = height;
        virtual void move(int x, int y) {
            this->x = x;
            this->y = y;
#endif // GUI_OBJECT_H

#include <iostream>
#include "guiobject.h"
#define TB_CHAR_WIDTH 8
#define TB_LINE_HEIGHT 12

class GUITextbox : public GUIObject {
        std::string text;
        GUITextbox(int x, int y, int width, int height) : x(x), y(y), width(width),
            height(height) {}
        GUITextbox(int x, int y, int width, int height, char* text) : x(x), y(y), width(width),
            height(height) {
            this->text = text;
        void draw() {
            int numChars = width/TB_CHAR_WIDTH;
            for (int i=0;i<text.length()/numChars+1;i++)
            glPrint(text.substr(i*numChars, (i+1)*numChars), x, y+(i*TB_LINE_HEIGHT),
            1.0f, 1.0f, 1.0f);
#endif // GUI_TEXTBOX_H

But it says in that GUITextbox has no field x, y, width or height. What's wrong?? Thanks in advance.

Share this post

Link to post
Share on other sites
Oh, you're right, that solved it, I didn't know that. Thanks for the info Roboguy I could've been stuck there for a long time.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!