Not sure about the errror
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#include <iostream>
#include <string>
using namespace std;
class Car
{
friend bool operator==(const Car &carA, const Car &carB);
public:
Car();
Car(const Car &otherCar);
Car(string aReportingMark, int aCarNumber, string aKind, bool aLoaded, string aDestination);
~Car();
void setup(string aReportingMark, int aCarNumber, string aKind, bool aLoaded, string aDestination);
void output();
Car & Car::operator=(const Car &carB);
private:
string reportingMark;
int carNumber;
bool loaded;
string destination;
};
class StringOfCars
{
public:
StringOfCars();
StringOfCars(const StringOfCars &otherStringOfCars);
~StringOfCars();
void output();
void push(const Car &car);
void pop(Car &car);
private:
Car *ptr;
static const int ARRAY_SIZE = 10;
int carCount;
};
StringOfCars::StringOfCars()
{
ptr = new Car[ARRAY_SIZE];
carCount = 0;
}
StringOfCars::StringOfCars(const StringOfCars &otherStringOfCars)
{
ptr = new Car[otherStringOfCars.ARRAY_SIZE];
for(int i = 0; i < otherStringOfCars.carCount; i++)
ptr[i] = otherStringOfCars.ptr[i];
carCount = otherStringOfCars.carCount;
}
StringOfCars::~StringOfCars()
{
delete [] ptr;
}
void StringOfCars::output()
{
if(carCount == 0)
{
cout << "NO cars" << endl;
}
else
{
for(int n = 0; n < carCount; n++)
{
ptr[n].output();
}
}
}
void StringOfCars::push(const Car &car)
{
if(carCount == ARRAY_SIZE)
{
cout << "The string of cars is full." << endl;
}
else
{
ptr[carCount] = car;
carCount++;
}
}
void StringOfCars::pop(Car &car)
{
if(carCount == 0)
{
cout << "The string of cars is empty." << endl;
}
else
{
carCount--;
car = ptr[carCount];
}
}
void input()
{
}
int main()
{
system("pause");
return 0;
}
|
I get the error "16:7: error: extra qualification 'Car::' on member 'operator=' [-fpermissive]"
What does this mean?
When declaring a class function within the class declaration itself class Car { ... };, you don't need the "Car::" scope resolution, it's redundant.
I tried removing it before and it just gave me a huge text of errors.
You don't have implementations for any of your Car class function definitions. I assumed you removed them for brevity.
Last edited on
Topic archived. No new replies allowed.