const类型类成员的初始化

const修饰类的成员变量的初始化只能在类的构造函数的初始化表中进行


下面是例子:

#include "stdafx.h"
#include 

class CConstPtrInit
{
public:
    CConstPtrInit():pTel(new int)
    {
        *pTel=200;
    }

    ~CConstPtrInit()
    {
    }

    void ShowInfo()
    {
        std::cout<<"*pTel value:"<<*pTel<





你可能感兴趣的:(C++)