compilation - indirection requires pointer operand and expected expression errors -


i keep getting errors similar these:

pitstop.cpp:36:23: error: indirection requires pointer operand          ('double' invalid)           cost = unleaded * gallons;                            ^ ~~~~~~~  pitstop.cpp:40:14: error: expected expression                      cost = super * gallons;                               ^ 


#include <iostream> #include <iomanip> using namespace std;  #define unleaded 3.45; #define super {unleaded + 0.10}; #define premium {super + 0.10};  /*      author: zach stow     date:      homework      objective: */  double cost, gallons; string gastype, finish, stop;  int main() {     for(;;)      {          cout <<"hi, welcome pitstop.\n";          cout <<"enter type of gas need:";         cin >> gastype;          cout << endl;          cout <<"enter amount of gallons need:";         cin >> gallons;         cout << endl;          if(gastype == "finish" || gastype == "stop")break;          else if(gastype == "unleaded")         {             cost = unleaded * gallons;         }         else if(gastype == "super")         {             cost = super * gallons;         }            else if(gastype == "premium")         {             cost = premium * gallons;         }      }        cout <<"you need pay:$" << cost << endl;      return(0);  } 

not c++ expert, i'm sure define constant need use #define directive followed symbol , value want assign (even if value expression, if such expression referencing constant), braces , trailing semicolon excessive:

// [...]  #define unleaded 3.45 #define super (unleaded + 0.10) #define premium (super + 0.10)  //[...] 

it compiled @ first attempt such corrections.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -