标签:
#include <iostream> class A { private: std::string a; public: A(std::string b) :a(b){} char& operator[](int b)const { return a[b]; } }; int main() { A a("hello");
//a[0]=‘j‘; 不能 char*p = &a[0];
*p = ‘j‘; 也不能,编译器信息:“return”: 无法从“const char”转换为“char &” std::cout << *p; }
标签:
原文地址:http://www.cnblogs.com/vhyc/p/5574821.html