由笔试题引发的知识点

#include <iostream>
#include <tchar.h>
using namespace std;
class node
{
     public:
     int count;
node():count(0){}
     void inc() const
     {
       if(count<2)
            cout<<"Object no: "<<count++<<endl;
     }
 };

int _tmain(void)
{ 
     node n;
     n.inc();
     n.inc();
 
     return 0;
}


留两个问题:

1,、该程序可否通过编译并正常运行,如果可以,输出是什么?

2、如何程序有错,如何修改?

此处牵扯到常量成员函数的知识点,该知识点详见下面文章:

http://blog.csdn.net/cai0538/article/details/7039639

你可能感兴趣的:(include)