struct BaseType
{
int x1;
float x2;
};
struct ChildType
{
int y1;
float y2;
};
Class Base
{
BaseType obj;
void funcBase(BaseType **ptr)
{
*ptr = &obj; // When this assignment happens ofcourse obj is of the BaseType as the LHS ptr is pointing to a BaseType
Now I want to write a C++ equivalent code of the following 2 algorithmic statements,
BaseType's obj.x1 = ChildTypes's obj.y1;
BaseType's obj.x2 = ChildTypes's.obj.y1;
}
};
class Child :: public Base
{
ChildType obj;
};
ベースから子のobj.y1にアクセスし、ベースのobj.x1に割り当てます。
ただし、ベースと子のオブジェクト名は同じ「obj」であることを覚えておいてください。
誰かが親切にこれで私を助けてくれますか?ありがとう。