-1
我:C++对象设计
// file model.h
#include "instrument.h"
class model
{
// A function which uses instruments and returns double.
double value(Instrument instruments);
}
现在文件instrument.h
// file instrument.h
class Instrument
{
// This function needs to use model.
double value2(model* md);
}
现在,在文件instrument.h
,我应该使用#include "model.h"
?这种看起来像一个糟糕的设计。
如何设计这两个对象的仪器和模型,以便他们知道并可以互相使用?
很好的答案。 'value'方法的'Instrument'参数也应该是一个指针,因为它现在是一个不完整的类型。 – Macmade
@Macmade no。对于参数你不需要一个完整的类型。 –
@Luchian:对于你没有调用的函数。 – Puppy