I have encountered a following error, may i know what does it mean?
pointTwoD.h:14: note: candidates are: pointTwoD& pointTwoD::operator=(const pointTwoD&)
below are the code snippets for pointTwoD.cpp and pointTwoD.h
Well since you haven't overloaded the assignment operator for pointTwoD, and your error is stating something about it, I can only assume that there is code using this class that is not posted that is causing the compiler to implicitly try to do something with it. Copy and paste the exact error message, also, post the call sites for this class as well as the Location class.
void showProgram()
{
cout<<"Welcome to Mission Plan program!"<<endl<<
"1)Input statistical data."<<endl<<
"2)Compute civ. index value (for all records)"<<endl<<
"3)Print top 5 exploration destinations."<<endl<<
"4)Print total travel distance."<<endl;
}
int main()
{
pointTwoD dataStore[100];
pointTwoD getData;
int counter=0;
locationData data;
string sunT;
int xCord,yCord,noOfEarthPlanet,noOfEarthMoon;
int choice;
float aveParticulateDensity;
float avePlasmaDensity;
showProgram();
cout<<"Please select your choice :";
cin>>choice;
switch(choice)
{
case 1 : cout<<"Input statistical data"<<endl;
cout<<"Please enter x-cordinate:";
cin>>xCord;
getData.setxCord(xCord);
cout<<"Please enter y-cordinate:";
cin>>yCord;
getData.setyCord(yCord);
cout<<"Please enter sun type: TYPE:";
cin>>sunT;
data.setSunType(sunT);
cout<<"Please enter no. of earth-like planets:";
cin>>noOfEarthPlanet;
data.setNoOfEarthPlanets(noOfEarthPlanet);
cout<<"Please enter no. of earth-like moons:";
cin>>noOfEarthMoon;
data.setNoOfEarthMoons(noOfEarthMoon);
cout<<"Please enter ave. particulate density (%-tage):";
cin>>aveParticulateDensity;
data.setAveParticulateDensity(aveParticulateDensity);
cout<<"Please enter ave. plasma density (%-tage):";
cin>>avePlasmaDensity;
data.setAvePlasmaDensity(avePlasmaDensity);
dataStore[counter]=data.toString();
counter++;
cout<<"Record succesfully stored. Going back to main menu."<<endl;
break;
default: cout<<"Invalid choice, please re-enter your choice."<<endl;
case 2:
data.computeCivicIndex(sunT,noOfEarthPlanet,noOfEarthMoon,aveParticulateDensity,avePlasmaDensity);
cout<<"Computation completed"<<endl;
}
return 0;
}
i have done it the way like in the locationData class, it works fine but i have no idea why this error appears when i try to link them together
Put your code in code tags, to the right of where you type your comments are these brackets <>, select the text you want in code and press that.
Here is your problem: dataStore[counter]=data.toString();dataStore[counter] is a pointTwoD and data.toString() returns a string, the compiler is telling you that there is a candidate operator, the assignment operator that it could use for this statement, however, the compiler will only give you a default operator... this is why it is just a candidate because you don't have operator=(const std::string&) for your pointTwoD class. Either implement it or change your logic there.