class Base{
public:
float a,b;
};
class Derived:public Base{
public:
int someInteger, otherInt;
void assignNthElement(vector<Base> &myArray,int i){
this=myArray[i-1];//??? How ???
}
void simpleMethodOfAssigningNthElement(vector<Base>&myArray,int i){
a=myArray[i-1].a;
b=myArray[i-1].b;
}
};
myArray에서 파생 클래스 내의 기본 클래스를 설명하는 값을 직접 복사하는 방법은 무엇입니까? "simpleMethodOfAssigningNthElement"에서 수행 한 것처럼 더 나은 방법일까요? 더 빠릅니다.파생 클래스에서 메서드를 통해 복사하여 기본 클래스 필드를 설정하는 방법?
감사합니다. – Opeww