tags:

views:

27

answers:

4

The compiler is giving me the following complaints about the following class:

class AguiWidgetBase
{
    //variables
    AguiColor tintColor;
    AguiColor fontColor;
    //private methods
    void zeroMemory();
    virtual void onPaint();
    virtual void onTintColorChanged(AguiColor color);
    void (*onPaintCallback)(AguiRectangle clientRect);
    void (*onTintColorChangedCallback)();


public:
    AguiWidgetBase(void);
    ~AguiWidgetBase(void);
    void paint();
    void setTintColor(AguiColor color);
    AguiColor getBackColor();
};


Warning 13  warning C4183: 'getBackColor': missing return type; assumed to be a member function returning 'int' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  26
Error   2   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  11
Error   3   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  11
Error   5   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  12
Error   6   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  12
Error   11  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  26
Error   12  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  26
Error   1   error C2146: syntax error : missing ';' before identifier 'tintColor'   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  11
Error   10  error C2146: syntax error : missing ';' before identifier 'getBackColor'    c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  26
Error   4   error C2146: syntax error : missing ';' before identifier 'fontColor'   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  12
Error   8   error C2061: syntax error : identifier 'AguiRectangle'  c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  17
Error   7   error C2061: syntax error : identifier 'AguiColor'  c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  16
Error   9   error C2061: syntax error : identifier 'AguiColor'  c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h  25

This should be working, I'm including the headers for those classes.

This is the h file:

//integer Point class
class AguiPoint {
    int x;
    int y;
public:
    int getX();
    int getY();
    void setX(int x);
    void setY(int y);
    void set(int x, int y);
    AguiPoint(int x, int y);
    AguiPoint();
    std::string toString();
    std::string xToString();
    std::string yToString();

};

//floating version of Agui Point
class AguiPointf {
    float x;
    float y;
public:
    float getX();
    float getY();
    void setX(float x);
    void setY(float y);
    void set(float x, float y);
    AguiPointf(float x, float y);
    AguiPointf(AguiPoint p);
    AguiPointf();
    std::string toString();
    std::string xToString();
    std::string yToString();
};

//Integer rectangle class
class AguiRectangle {
    int x;
    int y;
    int width;
    int height;
public:

    bool isEmpty();
    int getTop();
    int getLeft();
    int getBottom();
    int getRight();
    AguiPoint getTopLeft();
    AguiPoint getBottomRight();
};

class AguiColor {
    unsigned char r;
    unsigned char g;
    unsigned char b;
    unsigned char a;
void verifyColorBounds();
public:
    AguiColor(int r, int g, int b, int a);
    AguiColor(float r, float g, float b, float a);
    AguiColor();
    int getR();
    int getG();
    int getB();
    int getA();
};

Thanks

I include the main header in the WidgetBase and the main header includes the base types before it includes the widgetbase

A: 

If you already have the headers included i'd guess you need to fully qualify the names because of a namespace or that Aguiwidgitbase is in the wrong namespace? either way check the namespaces in the headers you included

jk
A: 

Check header files and namespaces. You may also need forward declarations.

DanDan
A: 

You may have a problem of include dependencies. Header guards preventing multiple definition (#pragma once, or #ifndef HEADER #define HEADER) can block your inclusion.

One answer can be forward declarations... for pointers to class, not for class members though (need to know storage size at compile time).

jv42
A: 

It seems you are not including the headers in the right order.

C++ is very sensitive to the order in which identifiers are declared. The compiler will process a source file (and any #include-s it finds along the way) in a sequential order and for every (non-builtin) identifier, the compiler must have seen a declaration before you can use it.

Bart van Ingen Schenau