在试图编译以下内容时,我会得到以下错误。(噢,它没有粘贴第一次尝试)
1\Codeblocks\Assignment2\travelLength.h|24|error:在一个声明中的C:\Users\Owner\Desktop\Study\C++\Assignment多个类型
在过去,我一直认为这是一个缺失";“然而,这一次什么也没有缺少(是吗?)我已经从下面粘贴的示例中删除了#include "travelZone.h“,但我仍然得到了使用error...ive的c++
是的我是student...frustrated...student
#ifndef TRAVELLENGTH_H
#define TRAVELLENGTH_H
#include<string>
#include<iostream>
class TravelLength
{
protected:
int itsLengthMinutes;
string itsName;
public:
TravelLength();
virtual ~TravelLength();
virtual void print() = 0; //display output for a travelpass object
virtual string getName() const = 0; //return string of its Name
virtual float PriceAccept(TravelZone* theZone) =0;
friend ostream& operator <<(std::ostream& outputStream, const TravelLength& thisTLength);
};
#endif发布于 2010-11-09 21:23:36
看起来,您正在尝试使用作为标准库(string,ostream)一部分的类型,而不引用标准名称空间。所有来自标准库的类型都应该以std::作为前缀。
发布于 2010-11-09 22:27:55
你确定你纠正了所有的std::问题吗?
这段代码编译(作为一个CPP文件)没有错误,在我看来是可以的:
#include<string>
#include<iostream>
class TravelZone;
class TravelLength
{
protected:
int itsLengthMinutes;
std::string itsName;
public:
TravelLength();
virtual ~TravelLength();
virtual void print() = 0; //display output for a travelpass object
virtual std::string getName() const = 0; //return string of its Name
virtual float PriceAccept(TravelZone* theZone) =0;
friend std::ostream& operator <<(std::ostream& outputStream, const TravelLength& thisTLength);
};
int main()
{
return 0;
}https://stackoverflow.com/questions/4138756
复制相似问题