Sign in to follow this  
NIm

Stupid mistakes...

Recommended Posts

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



Share this post


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

Share this post


Link to post
Share on other sites
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" 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
world.h:21: error: expected `;' before '(' token

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

Execution terminated




I don't get it. Why doesn't it see that addSpacething is a function?

Share this post


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

Share this post


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

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