C++ mutable关键字的使用

#include <iostream> //标准输入输出流
#include "Utils.h"
#include "Config.h"
#include "stdio.h"
#include "cloneable.h"
#include "IPerfomanceEvalShare.h"
#include <Windows.h>
using namespace xml_my_api;
using namespace xml_api;
using namespace std;//标准命名空间

#define ARY_SIZE 10

class CPork
{
public:
CPork(float price):m_fPrice(price){}
float GetPrice() const


{
m_fPrice += 100;
return m_fPrice;
};
private:

mutable float m_fPrice; //表示该成员变量在const修饰的函数中可以修改

};
int main()
{
CPork pork(100.5);
float fResult;
fResult = pork.GetPrice();
cout << fResult << endl;

int wait;
cin >> wait;

return 0;
}

 

posted @ 2013-07-20 13:22  Predator  阅读(180)  评论(0编辑  收藏  举报