#include "stdafx.h"#include<iostream>#include<cstring>using namespace std;class Clazz
{public: float x, y; string msg; const float& operator [] (uint8_t i) const { return (&x)[i]; } float& operator [] (uint8_t i) { return (&x)[i]; }
Clazz() {}
Clazz(float x, float y, string msg) :x(x), y(y), msg(msg) {}
};int main(void)
{
Clazz clazz = Clazz(1.0f,2.0f,"hello world");
cout << "clazz.x: " << clazz.x << endl;
cout << "clazz.y: " << clazz.y << endl;
cout << "clazz[0] " << clazz[0] << endl;
cout << "clazz[1] " << clazz[1] << endl;
cout << "clazz[2] " << clazz[2] << endl;
cin.get(); return 0;输出结果是怎么理解,有权威的解读或者定义能够解释吗
添加回答
举报
0/150
提交
取消