Stupid mistakes...

Started by
5 comments, last by Zahlman 17 years ago
I took a break from programming for a while, but I'm back at it, and lo and behold, I've run into trouble. Someone clever tell me whats wrong with me:

class world
{
    private:
    ID IDcounter;
    std::map<ID, boost::shared_ptr<spacething> > IDmap;
    public:
    ID getID(boost::shared_ptr<spacething>);
    boost::shared_ptr<spacething> getSpacethingPtr(ID id);
    void instantiateSpacething(boost::shared_ptr<spacething> initiate);
    void addSpacething;//(boost::share_ptr<spacething> other);
    void update(){}
    world();
    ~world();
};

Executing  make...
make.exe -f "C:\Documents and Settings\Owner\Desktop\clank\Makefile.win" all
g++.exe -D__DEBUG__ -c clank.cpp -o clank.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/clank/include"    -ggdb -pg -g3

In file included from spacething.h:10,
                 from frobnitz.h:4,
                 from clank.cpp:8:
world.h:21: error: variable or field `addSpacething' declared void

make.exe: *** [clank.o] Error 1

Execution terminated



Advertisement
I think you're missing a "()" after the "addSpacething" if it's a method.
Kippesoep
This line:
void addSpacething;//(boost::share_ptr<spacething> other);

Since you have the parameter list commented out, the compiler sees this as a member variable with type void. Clearly not allowed [smile].
wow, I really am not all here today. Heres the real code+error

class world{    private:    ID IDcounter;    std::map<ID, boost::shared_ptr<spacething> > IDmap;    public:    ID getID(boost::shared_ptr<spacething>);    boost::shared_ptr<spacething> getSpacethingPtr(ID id);    void instantiateSpacething(boost::shared_ptr<spacething> initiate);    void addSpacething(boost::share_ptr<spacething> other);    void update(){}    world();    ~world();};

Executing  make...make.exe -f "C:\Documents and Settings\Owner\Desktop\clank\Makefile.win" allg++.exe -D__DEBUG__ -c clank.cpp -o clank.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/clank/include"    -ggdb -pg -g3In file included from spacething.h:10,                 from frobnitz.h:4,                 from clank.cpp:8:world.h:21: error: variable or field `addSpacething' declared voidworld.h:21: error: expected `;' before '(' tokenmake.exe: *** [clank.o] Error 1Execution terminated


I don't get it. Why doesn't it see that addSpacething is a function?
In void addSpacething(), I think you misspelled boost::shared_ptr as boost::share_ptr.
Well then. That worked. Can anyone tell me why? WHy didn't it complain about what a 'share_ptr' was, instead of not recognizing the function declaration?
Strange things happen with error reporting for templates sometimes. You might want to ask the GCC mailing list instead, though, why they can't (or don't) give you a more accurate error message for this.

This topic is closed to new replies.

Advertisement