Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- class A {
- public:
- int m_variable = 5;
- }
- include iostream>
- using namespace std;
- void B::method() {
- // Why do get an error stating 'invalid use of non-static data member on this line?
- int x = (A::m_variable) * 2;
- cout << x << endl;
- }
- class B : public A {
- // ... whatever
- };
- class B {
- // ... whatever
- private:
- A someVar;
- };
- int x = someVar.m_variable * 2;
- class A {
- public:
- static int m_variable;
- };
Add Comment
Please, Sign In to add comment