"New type in constructor"?

Started by
2 comments, last by F1N1TY 17 years, 7 months ago
When I compile this code, it throws an error about "New types may not be defined in a return type" and "return type specification for constructor invalid." I don't know why it is doing this, it is just a normal constructor from a normal class. Here is the class:

class DialogBox
{
    int width;
    int height;
    int xpos;
    int ypos;
    TextureManager tman;
    //DialogBox(int w, int h, int x, int y);
    DialogBox();
    void RenderDBox(int x, int y, int pid);
}
and the source file:

...snip...
DialogBox::DialogBox()
{
}
...snip...
Could someone help me with this problem?
Advertisement
make a ; in the end of your class definition

and are you surposed make your constructor private?
regards/thallishI don't care if I'm known, I'd rather people know me
Place a semicolon after the bracket in your class definition. :)
"I'd rather know one thing, no matter how ordinary, than discourse endlessly on great issues." -- Galileo
Constructor needs to be public, else it can't be called. I think that's how it works anyway, correct me if I'm wrong. You should define you class more like this:

class DialogBox{private:    int width;    int height;    int xpos;    int ypos;public:    TextureManager tman;    //DialogBox(int w, int h, int x, int y);    DialogBox();    void RenderDBox(int x, int y, int pid);};// Add accessor methods for the width, height, xpos, and ypos to keep them safe.

:)
"I'd rather know one thing, no matter how ordinary, than discourse endlessly on great issues." -- Galileo

This topic is closed to new replies.

Advertisement