#include <cstdlib>
#include <iostream>
using namespace std;
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////CVector3
class CVector3{
private:
double x;
public:
CVector3();
double getX();
void setX(double);
};
CVector3::CVector3(){
x=0;
}
double CVector3::getX(){
return x;
}
void CVector3::setX(double newX){
x=newX;
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////CForce
class CForce{
private:
CVector3 f1;
public:
CForce();
CVector3 getF1();
//void setF1();
};
CForce::CForce(){
f1.setX(0);
}
CVector3 CForce::getF1(){
return f1;
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
CVector3 v1,v2;
v1.setX(3);
printf("v1.x = %0.2lf\n",v1.getX());
CForce F;
//printf("v1.x=%0.2lf\n",F.getF1.getX()); //編譯錯誤 insufficient contextual information to determine type
v2=F.getF1();
printf("v2.x = F.f1.x = %0.2lf\n",v2.getX());
system("PAUSE");
return EXIT_SUCCESS;
}
I2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxpb3N0cmVhbT4gCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Ci8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vL0NWZWN0b3IzCmNsYXNzIENWZWN0b3IzewogICAgcHJpdmF0ZToKICAgICAgICBkb3VibGUgeDsKICAgIHB1YmxpYzoKICAgICAgICBDVmVjdG9yMygpOwogICAgICAgIGRvdWJsZSBnZXRYKCk7CiAgICAgICAgdm9pZCBzZXRYKGRvdWJsZSk7ICAgICAgICAgCn07CkNWZWN0b3IzOjpDVmVjdG9yMygpewogICAgeD0wOwp9CmRvdWJsZSBDVmVjdG9yMzo6Z2V0WCgpewogICAgcmV0dXJuIHg7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