【发布时间】:2014-03-26 03:03:53
【问题描述】:
我有一个项目要处理。 它有一个 Temp 类,它的功能很少。 然后还有另一个 Class Weather,它将数据存储在名为 Observation 的 Struct 中。这个结构有一个类型为 Temp 的字段。
Class Temp {
Temp();
Temp(string t);
string getTemp();
void setTemp(string temp);
};
Class Weather
{
@贝塔
在我的天气课上 我很少有调用类 Temp 的函数
// Weather.h
public:
void record(Temp temp, float d); // error 'Temp' has not been declared
Temp getTemp() const; // 'Temp' does not name a type
protected:
struct Observation
{
Temp t;
int deg;
};
Observation obs[20];
};
// Weather.cpp
void Temp::record(Temp temp, float d){
obs[i].temp = temp;
obs[i].deg = d;
i++;
}
我已尝试创建 Temp 和 Weather 的实例。 但我无法到达结构内的 Temp t。
int main(){
Temp t;
Weather w;
w.record(tt,dd);
}
请指导我...
【问题讨论】: