编译文件时出现C++错误

tf.*_*.rz 0 c++ compiler-errors header

我有一个名为BottlingPlant的课程.我创建了以下头文件:

#ifndef __BOTTLINGPLANT_H__
#define __BOTTLINGPLANT_H__

#include <iostream>

class BottlingPlant {
public:
BottlingPlant( Printer &prt, NameServer &nameServer, unsigned int numVendingMachines, unsigned int maxShippedPerFlavour, unsigned int maxStockPerFlavour, unsigned int timeBetweenShipments );
void getShipment( unsigned int cargo[ ] );
void action();  
};

#endif
Run Code Online (Sandbox Code Playgroud)

以下.cc文件:

#include <iostream>
#include "PRNG.h"
#include "bottlingplant.h"

BottlingPlant::BottlingPlant( Printer &prt, NameServer &nameServer, unsigned int numVendingMachines, unsigned int maxShippedPerFlavour, unsigned int maxStockPerFlavour, unsigned int timeBetweenShipments ) {


}

void BottlingPlant::getShipment( unsigned int cargo[ ] ) {

}

void BottlingPlant::action() {

}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译.cc时,它会在.cc和.h中给出错误:

BottlingPlant::BottlingPlant( Printer &prt, NameServer &nameServer, unsigned int numVendingMachines, unsigned int maxShippedPerFlavour, unsigned int maxStockPerFlavour, unsigned int timeBetweenShipments )
Run Code Online (Sandbox Code Playgroud)

)&令牌之前有预期.这对我没有任何意义,因为没有开放(.我只是不确定为什么它会给出这个错误.Printer并且NameServer只是单独的类作为项目的一部分但是..我是否需要包括他们的头文件或否?

任何帮助是极大的赞赏!

Wyz*_*a-- 5

您需要包含您正在使用的任何类的头文件,甚至包括同一项目中的类.编译器将每个单独的源文件作为单独的转换单元进行处理,如果定义它的标头未包含在该转换单元中,则它将不知道该类是否存在.