The following statement is wrong (C)
A, the static member function does not have this pointer.
B, the static member function cannot directly access a non-static member.
C, static data members cannot be initialized in the definition body of a class.
D, static data members exist independent of any object of the class and are not part of the object of that class type.
Analyze a option
A static member function does not have the this pointer because it is not associated with any object. In this sense, it cannot access non-static data members that belong to a class object, nor can it access a non-static member function, which only calls the rest of the static member functions.
b option
//the following class definitions, The following is a static member function that accesses a non-static function directly error class base {static void fun_static (); static void fun_non_static (); }; void base :: Fun_static () {fun_non_static ();}
//如下的类定义,static成员函数可以通过对象间接访问非static函数classbase{ staticvoid fun_static(base &a); staticvoid fun_non_static(); };voidbase::fun_static(B){ B.fun_non_static();}
C option
class base { static const int i=0 ; //Yes, but the data member must still be defined outside the definition body of the class static int j=0 ; //can not static int m; //can be const int count; //can be const int count=0 //can };
It is also said that a very mass data member cannot be initialized in the class definition body, and constant is possible.
d option
Non-static data members exist in each object of the class type, unlike normal data members, where static data members exist independent of any object of the class, and each static data member is an object associated with the class. is not associated with the object of the class.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Reflections on a written question