0
class methods in C++ are private by default.you have to declare them public. #include <iostream> using namespace std; class BankAccount { public: void sayHi() { cout << "Hi" << endl; } }; int main() { BankAccount test; test.sayHi(); }
29th May 2022, 10:07 AM
Bob_Li
Bob_Li - avatar
0
or maybe you are asking about scope resolution operators? https://www.tutorialspoint.com/Scope-resolution-operator-in-Cplusplus#:~:text=The%20scope%20resolution%20operator%20can,during%20a%20block%20or%20class. #include <iostream> using namespace std; class X { public: static int count; }; int X::count = 10; // define static data member int main () { int X = 0; // hides class type X cout << X::count << endl; // use static member of class X }
29th May 2022, 10:14 AM
Bob_Li
Bob_Li - avatar