'static' keyword in c vs c++?

V

vib.cpp

I begin to learn C++ when I do not know much about c, just as a lot of
people say that I needn't to learn c first and then stepped to learn c+
+.
But when I was learning the keyword 'static' in c++, it was said that
'static member' is belonging to a class not to an object, so it seems
that static member is a concept from the object-based concepts, but as
I know there is also a 'static' keyword even in c, so what's the
difference about the word in c and c++? why is it also necessary in c
when there is no class ,no objects?
 
A

Alf P. Steinbach

* (e-mail address removed):
I begin to learn C++ when I do not know much about c, just as a lot of
people say that I needn't to learn c first and then stepped to learn c+
+.
But when I was learning the keyword 'static' in c++, it was said that
'static member' is belonging to a class not to an object, so it seems
that static member is a concept from the object-based concepts, but as
I know there is also a 'static' keyword even in c, so what's the
difference about the word in c and c++? why is it also necessary in c
when there is no class ,no objects?

The 'static' keyword retains its C meaning in C++. In addition C++ uses that
keyword for static class members. For static data members the effect on lifetime
is just about the same as for ordinary static variables.

Your textbook should be explaining this.

Which textbook are you using?


Cheers & hth.,

- Alf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top