Give the error c++ help me please!!

#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>

#include <cstring>
using namespace std;

// Inheritance to create two new classes.cpp : Defines the entry point for the console application.
//

class Car
{
protected:
string Type;
string ARR;
int number;
string kind;
string loaded;
string destination;
string order;

public:
//default constructor
Car(void);
//a copy constructor
Car(const Car &obj);
//constructor that has five parameters
Car(string newType, string neworder,string newARR,int newnumber,string newloaded,string newdestination);
~Car(void);
void buildCar(string newType,string newARR,string newkind,int newnumber,string newloaded,string newdestination,string neworder);
void setKind(string kind);
void setUpCar();


};

int main()
{
string FreightCar ;
string PassengerCar;
string kind;

string line;
ifstream carsFile ("cars.txt");
cout<<"Type order ARR number kind loaded destination\n";
if (carsFile.is_open())
{
while (carsFile.good() )
{
getline (carsFile,line);
char* cstr = new char [line.size()+1];
strcpy (cstr, line.c_str());
char* splitter= strtok(cstr,"|");
int count=0;

string Type;
string order;
string ARR;
int number;
string kind;
string loaded;
string destination;
string FreightCar ;
string PassengerCar;

while (splitter != NULL)
{
if(count==0){
Type=splitter;

}
if(count==1){
order=splitter;

}
if(count==2){
ARR=splitter;

}
if(count==3){
number=atoi(splitter);

}
if(count==4){
kind=splitter;

}
if(count==5){
loaded=splitter;

}

if(count==6){
destination=splitter;

count=-1;
}
splitter = strtok (NULL, "|");
count++;
}

if(strcmp(Type.c_str(),"Car")==0){
Car Cartemp( Type,order,ARR,number,loaded,destination);
Cartemp.setKind(kind);
Cartemp.setUpCar();

}
if(strcmp(Type.c_str(),"FreightCar")==0)
{
FreightCar ,FreightCar(Type,order,number, ARR,loaded,destination);
FreightCar. setkind(kind);
FreightCar.setUpCar();
}
if(strcmp(Type.c_str(),"PassengerCar")==0){
PassengerCar PassengerCartemp(Type,order,ARR,number, kind,loaded,destination);
PassengerCartemp.setKind(kind);
PassengerCartemp.setUpCar();
}

}
carsFile.close();//close file
}
else{ cout << "No such file\n\n";}


//delay
system("pause");

return 0;
}




||In function 'int main()':|
|114|error: no match for call to '(std::string {aka std::basic_string<char>}) (std::string&, std::string&, int&, std::string&, std::string&, std::string&)'|
'std::string' has no member named 'setUpCar'|
expected ';' before 'PassengerCartemp'|
'PassengerCartemp' was not declared in this scope|
||=== Build finished: 4 errors, 0 warnings (0 minutes, 0 seconds) ===|
Last edited on
Just look at the line of the error. What is that comma doing there? Is the first FreightCar supposed to be the type? You probably meant Car in that case.
yes
error: no match for call to '(std::string {aka std::basic_string<char>}) (std::string&, std::string&, std::string&, int&, std::string&, std::string&, std::string&)'

if(strcmp(Type.c_str(),"FreightCar")==0)
{
FreightCar ,FreightCar(Type,order,kind,number, ARR,loaded,destination);
FreightCar. kind();
FreightCar.setUpCar();


in this line give the error
please help me.
Last edited on
What is FreightCar ,? After you have fixed that you will probably get a more useful error message that will help you fix the rest.
yes my problem is that how can i fix FreightCar ?


Make two classes that inherit from the Car class:   FreightCar and PassengerCar.
Each class will need a default constructor, a copy constructor, and a constructor that has five parameters
You have only created the Car class. If you don't know the difference between a class and an object/variable then read up about it before continuing.
Topic archived. No new replies allowed.