我在这里有一个类的标头规范:
#ifndef FIXEDWINGAIRCRAFT_H
#define FIXEDWINGAIRCRAFT_H
#include <iostream>
class FixedWingAircraft
{
private:
struct Airframe
{
double weight;
};
struct Engine
{
double weight;
double fuel;
};
struct Radio
{
bool state;
double weight;
};
struct Pilot
{
int proficiency;
double weight;
};
public:
void setAirframe(double w)
{
Airframe.weight = w;
}
void setEngine(double w, double f)
{
Engine.weight = w;
Engine.fuel = f;
}
void setRadio(bool s, double w)
{
Radio.state = s;
Radio.weight = w;
}
void setPilot(int p, double w)
{
Pilot.proficiency = p;
Pilot.weight = w;
}
};
#endif
但是当我尝试编译时,我得到了大量的语法错误:
error C2143: syntax error : missing ';' before '.'
我假设这些是指 setter 函数,但我不明白为什么这会导致问题。我错过了什么?