C++??????????const
???????????? ???????[ 2014/5/4 10:36:27 ] ????????C++ ???? net
????1-3
//error C2166: ?????? const ????
#include "stdafx.h"
#include "iostream"
using namespace std;
class Text{
public:
void printconst(void) const{cout<<"hello"<<endl; k=1;}
void print(void){cout<<"hello"<<endl;}
private:
int k;
};
int main(void)
{
Text a;
a.printconst();
return 0;
}
|
????????????????????
#include "stdafx.h"
#include "iostream"
using namespace std;
class Text{
public:
void printconst(void) const{k=1000;cout<<k<<endl;}
void print(void){cout<<"hello"<<endl;}
private:
static int k;
};int Text::k=500;
const Text a;
int main(void)
{
a.printconst();//ok
cin.get();
return 0;
}
|
?????????1000
????1-4
//error C2662: “Text::print”: ?????“this”????“const Text”????“Text &”
#include "stdafx.h"
#include "iostream"
using namespace std;
class Text{
public:
void printconst(void) const{cout<<"hello"<<endl;print();}
void print(void){cout<<"hello"<<endl;}
private:
int k;
};
int main(void)
{
Text a;
a.printconst();
return 0;
}
|
????2-1
//error C2662: “Text::print”: ?????“this”????“const Text”????“Text &”
#include "stdafx.h"
#include "iostream"
using namespace std;
class Text{
public:
void printconst(void) const{cout<<"hello"<<endl;}
void print(void){cout<<"hello"<<endl;}
private:
int k;
};
const Text a;
int main(void)
{
a.printconst();//ok
a.print();//error
return 0;
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????