error when use of static class member

Started by
5 comments, last by McZ 20 years, 8 months ago
I cant use any Static tools in my base shader.. why do I get this error ? cShaderBase { public: class cShaderTools { ... ... }; static cShaderTools Tools; ... ... }; error LNK2001: unresolved external symbol "public: static class cShaderBase::cShaderTools cShaderBase::Tools" (?Tools@cShaderBase@@2VcShaderTools@1@A)
Advertisement
You need to provide an actual definition of any static member in a .cpp file.

Thus, add in a .cpp file:

cShaderBase::cShaderTools Tools;

"cShaderBase {" should be "class cShaderBase {"
and you can''t define a class "cShaderTools" within another class "cShaderBase", I suppose.

Try define "cShaderTools" outside "cShaderBase".

-------------------------------
Anton Karlsson
Klingis Entertainment
Games with silly humor

Just dreaming wont make you (more) skilled in game programming/development.
You can define a class A inside an other class B but as i can remember this class will be kind of "private" (you can create objects of class A only inside class B )
Sphax
Yes, you can nest class definitions.
Anonymous is right - you specified that your class has a static variable in it, but you must actually create it in a source file somewhere. If you do it in the header you will probably get more linker errors - it has to be declared once and only once.

In other words - putting an int variable in your class doesn''t actually create a variable. You have to create an instance of the class before anything actually happens. Since a static variable only exists in one place and won''t be created when you create an instance of the class, you must create the variable manually.

quote:Original post by Sphax
You can define a class A inside an other class B but as i can remember this class will be kind of "private" (you can create objects of class A only inside class B )

You can create instances of nested classes if you declare them public:
Base::Nested instance;  
STL uses this for iterators:
std::vector< int >::iterator pV;  


[edited by - Enselic on September 2, 2003 6:34:27 AM]
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
thanks "Anonymous Poster" it works perfekt now

This topic is closed to new replies.

Advertisement