33,311
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class Pt
{
public:
float x,y,z;
Pt &operator ()(float a,float b,float c)
{
x=a;
y=b;
z=c;
return *this;
}
};
int main()
{
Pt s;
Pt b=s.operator()(3,4,5); //这个没什么问题
Pt c=(Pt)(3,4,5); //我想要的是这样写。。。类似CRect(1,1,100,100)这种可以实现吗? 这里是错的
return 0;
}
#include <iostream>
using namespace std;
class Pt
{
public:
float x,y,z;
Pt(){}//
Pt(float a,float b,float c)//
{
x=a;
y=b;
z=c;
}
Pt &operator ()(float a,float b,float c)
{
x=a;
y=b;
z=c;
return *this;
}
};
int main()
{
Pt s;
Pt b=s.operator()(3,4,5); //这个没什么问题
Pt c=Pt(3,4,5); //我想要的是这样写。。。类似CRect(1,1,100,100)这种可以实现吗? 这里是错的
return 0;
}