Sign in to follow this  
Niddles

"New type in constructor"?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

:)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this