/*******************************************************
*author:彭晓林
*copyright: 版权所有,翻版不究
*function: 类成员常量和引用的初始化示例
******************************************************/
#include <iostream>
#include <string>
using namespace std;
class DEMO
{
public:
DEMO (int a, int b):x(1), y(z), z(b)
{
cout<<"构造函数被调用:/n";
cout<<"x = "<< x<<endl;
cout<<"y = "<< y <<endl;
cout<<"z = "<< z <<endl;
}
private:
const int x;
int z;
int &y;
};
int main()
{
DEMO *p = new DEMO(1,2);
delete p;
while(1);
}