+ 4

int A :: b; what does this instruction mean?

the above code is declared below a class 'A' and b is the data member of the class A.

22nd May 2017, 12:39 PM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
5 odpowiedzi
+ 10
:: is the scope resolution operator. It's used to access and initialize static class or namespace members.
22nd May 2017, 1:28 PM
Karl T.
Karl T. - avatar
+ 5
Because that's the default value.
22nd May 2017, 1:37 PM
Karl T.
Karl T. - avatar
+ 2
class A { public: static int b; }; int A::b; int main() { A x; cout << x.b; } i get the out put has '0' but i didnt declare the value for b then how? and what does " int A: b; " mean in this program?? also i just started learning c and c++😅
22nd May 2017, 1:22 PM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
+ 2
@ helioform yeah i can get it but i have not initialized the value of 'b' anywhere then how does it print the value has "0".
22nd May 2017, 1:35 PM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
- 3
A::b mean A derive class, b base class.. did you really read and learn the C++ course ?
22nd May 2017, 12:54 PM
Mugfirfauzy Siregar
Mugfirfauzy Siregar - avatar