1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
-
- #include <iostream>
- class Base
- {
- public:
- Base()
- {
- m_A = 100;
- }
- void func()
- {
- std::cout << "Base - func()调用" << std::endl;
- }
- void func(int a)
- {
- std::cout << "Base - func(int a)调用" << std::endl;
- }
- int m_A;
- };
- class Son :public Base
- {
- public:
- Son()
- {
- m_A = 200;
- }
- void func()
- {
- std::cout << "Son - func()调用" << std::endl;
- }
- int m_A;
- };
- void test01()
- {
- Son s;
- std::cout << "Son m_A = " << s.m_A << std::endl;
-
- std::cout << "Base m_A = " << s.Base::m_A << std::endl;
- }
- void test02()
- {
- Son s;
- s.func();
-
- s.Base::func();
-
-
- s.Base::func(100);
- }
- int main()
- {
-
-
- test02();
- system("pause");
- return 0;
- }
|