c++结构体初始化
c++结构体构造不能加返回值类型
typedef struct vec3
{
int x,y,z ;
vec3(){
x = y = z = 0;
}
}Vector3;
c++结构体重载操作符
注:出现错误:overloaded ‘operator<<’ must be a binary operator
需要使用友元函数定义
struct manStrct
{
std::string name;
int price;
friend ostream & operator<< (ostream &out ,manStrct &str)
{
out << "名字:" << str.name << "price:"<<str.price << std::endl;
return out ;
}
};