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;
}

 

原文链接: https://www.cnblogs.com/ganquanfu2008/p/3202282.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    C++ mutable关键字的使用

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/96600

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月10日 上午3:47
下一篇 2023年2月10日 上午3:47

相关推荐