结合网上的一些资料,通过自己的一番摸索,得出了一点个人见解。现在写下来,希望与各位同学共同探讨,共同进步。
以下所有代码均是在VS2012下测试。

一个普通的基类

#include <iostream>
namespace std;
   3:  
class Base
   5: {
public:
   7:     Base():
   8:         i(0)
   9:     {
  10:     }
void test(){
 << i << endl;
  13:     }
void virtualTest()
  15:     {
 << i << endl;
  17:     }
void staticTest()
  19:     {
 << endl;
  21:     }
  22:  
  23:  
  24:  
private:
int i;
  27:  
  28: };
  29:  
int main()
  31: {
  32:     Base b;
  33:     b.test();
  34:     b.virtualTest();
  35:     Base::staticTest();
  36:  
return 0;
  38: }

相关文章:

  • 2021-11-27
  • 2022-02-03
  • 2022-01-22
  • 2021-06-14
  • 2022-12-23
猜你喜欢
  • 2021-10-17
  • 2021-05-25
  • 2021-10-21
  • 2021-08-14
  • 2021-09-16
相关资源
相似解决方案