Hello,
Can somebody tell me what this error means?
: error C2676: binary '*' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a type acceptable to the predefined operator
I'm trying to create a function that calculates the cost of a tank of gas according to user input. I'm using multiple files so I'll show a snippet of the parts I've entered.
Code:
#ifndef _HEADER_H
#define _HEADER_H
#include<iostream>
#include<string>
using namespace std;
enum VehicleType{Automobile,Airplane,Train};
enum FuelKind{Gasoline,JetFuel,Diesel};
//==========================================
struct VehicleInfo
{
string RateOfSpeed;
string FuelCost;
string TankSize;
string mpg;
};
//============================================
class CVehicle
{
protected:
VehicleInfo vinfo;
VehicleType type;
FuelKind ftype;
double CostFullLoad; //new here
public:
CVehicle(VehicleInfo, VehicleType t,FuelKind f);
CVehicle(){}
void GetInfo();
void CalcFullLoadCost(); //new here
virtual void WriteData();
};
#endif
That was the Header file.
Code:
void CVehicle::GetInfo()
{
cout<<"\nEnter How Fast: ";
cin>>vinfo.RateOfSpeed;
cout<<"\nEnter Cost Per Gallon: ";
cin>>vinfo.FuelCost;
cout<<"\nHow many gallons will tank hold: ";
cin>>vinfo.TankSize;
cout<<"\nHow many miles per gallon: ";
cin>>vinfo.mpg;
}
//============================================
//the error is on this line
void CVehicle::CalcFullLoadCost() //new
{ CostFullLoad=(vinfo.TankSize * vinfo.FuelCost); }//new
//============================================
I am using a structure if that makes a difference. It doesn't seem to recognize the multiplication operator. Thank you for any help! MCorn