开发者

c++ compiler errors

I get the following error when trying to compile the following. (oops it didnt paste first try)

C:\Users\Owner\Desktop\Study\C++\Assignment 1\Codeblocks\Assignment2\travelLength.h|24|error: multiple types in one declaration|

In the past I've always thought this to be a missing ";", however th开发者_Python百科ere is nothing missing this time (is there?). I have removed the #include "travelZone.h" from the example pasted below but i still get the error...ive had it with c++

yes im a 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


It looks like you are trying to use types that are part of the standard library (string, ostream) without referencing the standard name space. All of the types that are from the standard library should be prefaced with std::


Are you sure you corrected all the std:: problems?

This code compiles (as a single CPP file) without error, and looks OK to me:

#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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜