Here is a full example the definition that does not work, I guess, because of the Motor declaration in Car. I don't see how an external definition can work. Error: "Unknown type name 'Motor' Motor Diesel;
Code:
struct Gauge
{
int Dial;
Gauge(int dial) : Dial(dial) {}
};
struct Car
{
int Foo;
/*struct Motor : Gauge
{
Motor(int dial) : Gauge(dial) {}
void MotorFunction(int increment, Car& car) { car.CarFunction(increment); }
};*/
Motor Diesel;
Car(int foo, int gauge) : Foo(foo), Diesel(gauge) {}
int CarFunction(int increment) { return Foo += increment; }
};
struct Car::Motor : Gauge
{
Motor(int dial) : Gauge(dial) {}
void MotorFunction(int increment, Car& car) { car.CarFunction(increment) }
};
int main()
{
Car A(1, 2);
A.Diesel.MotorFunction(5, A);
std::cout << A.Foo << std::endl;
return 0;
}