#include <iostream>
#include <string>
using namespace std;
class Base
{
public:
static int A;
public:
static void fun()
{
cout << "static func" << endl;
}
};
int Base::A = 230;
class Son : public Base
{
public:
static int A;
public:
static void fun()
{
cout << "static func" << endl;
}
};
int Son::A = 1;
void test()
{
Son s;
cout << s.A << endl;
cout << s.Base::A << endl;
cout << Son::A << endl;
cout << Son::Base::A << endl;
}
void Test()
{
Son s;
s.fun();
}
int main()
{
Test();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class Base
{
public:
Base()
{
ma = 10;
}
void func()
{
cout << "Base - func() " << endl;
}
void func(int x)
{
cout << "The func(int x) can not run" << endl;
}
int ma;
};
class Son : public Base
{
public:
Son()
{
ma = 200;
}
void func()
{
cout << "Son - func() " << endl;
}
int ma;
};
void test()
{
Son s;
cout << "This is the son' " << s.ma << endl;
cout << "This is the Base'a " << s.Base::ma << endl;
}
void Test()
{
Son s;
s.func();
s.Base::func();
s.func(10005);
s.Base::func(1000);
}
int main()
{
Test();
return 0;
}