2-2

#include "stdafx.h"
#include "iostream"
using namespace std;
class Text{
public:
void printconst(void) const{cout<<k<<endl;}
void print(void){cout<<"hello"<<endl;}
Text()
{
k=500; //修改成功
}
private:
int k;
};
const Text a;
int main(void)
{
a.printconst();//ok
cin.get();
return 0;
}

  输出: 500