S**Y 发帖数: 136 | 1 I have a class A with a public static member
class A{
...
public:
static int i;
private
int j,k;
char* s;
....
}
in the main program, I have
A a1;
I understand that a1 will be in stack, a1's j, k will be in stack too; s wil
l point to a dynamically allocated heap(if new-ed).
but how about the static variable i? It belongs to class A. Will it be in th
e data section?
Thanks a lot. | X****r 发帖数: 3557 | 2 Yes (or the .bss section)
【在 S**Y 的大作中提到】 : I have a class A with a public static member : class A{ : ... : public: : static int i; : private : int j,k; : char* s; : .... : }
| O*******d 发帖数: 20343 | 3 在标准的C++里,你必须要在一个不是头文件的文件里写一行
int A::i;
这就可以看出A::i是在data section. 和其它static data一样。 | S**Y 发帖数: 136 | 4 thanks! guys..
【在 O*******d 的大作中提到】 : 在标准的C++里,你必须要在一个不是头文件的文件里写一行 : int A::i; : 这就可以看出A::i是在data section. 和其它static data一样。
|
|