![]() |
Undefined reference
Code:
.............................Thank You for your help |
Re: Undefined reference
I don't get the same error in Visual Studio 2010:
Code:
class statictest1>c:\users\dave\documents\visual studio 2010\projects\cack\cack.cpp(37): error C2248: 'statictest::defaultint' : cannot access private member declared in class 'statictest' 1> c:\users\dave\documents\visual studio 2010\projects\cack\cack.cpp(17) : see declaration of 'statictest::defaultint' 1> c:\users\dave\documents\visual studio 2010\projects\cack\cack.cpp(16) : see declaration of 'statictest' 1>c:\users\dave\documents\visual studio 2010\projects\cack\cack.cpp(39): error C2248: 'statictest::privateint' : cannot access private member declared in class 'statictest' 1> c:\users\dave\documents\visual studio 2010\projects\cack\cack.cpp(23) : see declaration of 'statictest::privateint' 1> c:\users\dave\documents\visual studio 2010\projects\cack\cack.cpp(16) : see declaration of 'statictest' If I uncomment and the friend definition then this compiles and runs without error. Don't forget class members are private by default so tourist_name and the other 4 will need initialising by a friend function (or a class static function). If I uncomment the three "int statictest::..." lines then I get errors that are probably equivalent to your undefined references: 1>Cack.obj : error LNK2001: unresolved external symbol "private: static int statictest::privateint" (?privateint@statictest@@0HA) 1>Cack.obj : error LNK2001: unresolved external symbol "public: static int statictest::publicint" (?publicint@statictest@@2HA) 1>Cack.obj : error LNK2001: unresolved external symbol "private: static int statictest::defaultint" (?defaultint@statictest@@0HA) At a guess you probably need to go back and RTFM on how static class variables work. Are you sure you definitely need them to be static? Static class members are independent from any specific instance of that class; they are effectively global variables available within class scope to all objects of that class, and given the names of your variables it seems that static is exactly what you *don't* want. I would have thought that each BookingDetails object would need its own tourist name, booking id, room id etc. |
Re: Undefined reference
Thank You
|
| All times are GMT +5.5. The time now is 10:00. |