Powiedzmy mam 2 klasy:
class C1 {
public:
int x;
void metod1(){cout<<"metoda1"<<endl;}
};
class C2 {
public:
int y;
void metod2(){cout<<"metoda2"<<endl;}
};
i chciałbym użyć metod2 na obiekcie klasy C1. Czy jest to możliwe bez dziedziczenia?
np.
int main() {
C1 kl1;
C2 kl2;
kl1.metod2();
return 0;
}
Czy po prostu źle zaprojektowałem program.