Re: static variable
On Mar 5, 1:17 am, Carmen Sei <fatwallet...@yahoo.com> wrote:
does static in C++ is exactly the same as in Java?
Not really. To begin with, many of the contexts where you might
use static in C++ don't exist in Java.
Static member variables in C++ are fairly similar to static
member variables in Java, at least if you abstract the dynamic
loading of Java.
the following static variable is Class variable that I can
call by Class Name
Configuration.RemoteType = xx;
#######################
class Configuration {
public:
Configuration();
void Initialize();
public:
static RemoteType RemoteType;
static ControllerType ControllerType;
};
The syntax is different in C++. There is no instance of the
class type itself, and you use the scope resolution operator to
access static class members, e.g.: Configuration::RemoteType.
(Alteratively, if you have an instance, you can access the
variable just as if it were a non-static member of that
instance.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34