🔒 Locked
static members
Advertisement
Original Post
I though you had to leave out the "static" in the definition?
.H
Edited by - Clash Rocker on April 18, 2001 7:02:32 AM
.H
|
Edited by - Clash Rocker on April 18, 2001 7:02:32 AM
Nope, you use the static each time.
Are you even trying to be intelligent?
''cuz if you are, it ain''t workin''
Down with Tiberia!
Are you even trying to be intelligent?
''cuz if you are, it ain''t workin''
Down with Tiberia!
I am not sure about other compiler but in VC++, you certainly DONT need to include the static in your definition. It is enough if we mention it in out declaration.
I have a few static variables in my project, where I have the keyword static in the declaration alone. I dont use the keyword static in my definitions. It works perfectly for me.
Thanks
Arun
I have a few static variables in my project, where I have the keyword static in the declaration alone. I dont use the keyword static in my definitions. It works perfectly for me.
Thanks
Arun
Well I got around to trying it out on gpp. And it compiled
with zero errors when I left out that static on the function
definition.
with zero errors when I left out that static on the function
definition.
You should not use static in the definition, because that use of static has nothing to do with static data members. This is the correct way to do it:
// in the header file:
class someclass
{
public:
static int data;
};
// in the source file:
int someclass::data;
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement