Hello all,
I just came from programming class (c++). The program i wrote won't compile for reasons unknown (compiling from Darwin). I've just started using classes in c++ so i am kind of new to this, but my teacher almost swears that my code would funtion on a windows machine, so it has to be the Os. here's the the code, really simple:
these are the error messages I am getting
I am guessing classes have a different decalration in unix.Any help?
I just came from programming class (c++). The program i wrote won't compile for reasons unknown (compiling from Darwin). I've just started using classes in c++ so i am kind of new to this, but my teacher almost swears that my code would funtion on a windows machine, so it has to be the Os. here's the the code, really simple:
Code:
#include<iostream>
using namespace std;
class BombaGas{
private:
float litros, prexlit, cant, tot;
public:
BombaGas();
BombaGas(float,float);
void despliega();
float despacha(float);
};
BombaGas:BombaGas(){
litros=900;
prexlit=7.5;
cant=0;
tot=0.0;
}
BombaGas:BombaGas(float lit, float pre){
litros=lit;
prexlit=pre;
cant=0;
tot=0.0;
}
void despliega(){
cout<<"Cantidad de Gas"<<litros<<endl;
cout<<prexlit<< "precio por litro"endl;
}
float despacha(float x) {
litros=litros-x;
tot=(prexlit*x);
return tot;
}
int main(){
char op;
float ven;
float total;
BombaGas autombile, chevy(500,5) ;
do{
cout<<"#$#$#$ MENU #$#$#$"<<endl;
cout<<"Ver contenido Actual 1."<<endl;
cout<<"Compra de Gas 2."<<endl;
cout<<"Salir 3."<<endl;
cin>>op;
switch(op){
case'1': automobile.despliega();
chevy.despliega();
break;
case'2': cout<<"Cuantos litros quieres?"<<endl;
cin>>cant;
total=despacha(cant);
cout<<"Se cobra"<<total;
break;
case'3':
break;
}
while(op!='3');
return 0;
}
these are the error messages I am getting
Code:
bombagas.cpp: In function `void despliega()':
bombagas.cpp:33: error: 'litros' was not declared in this scope
bombagas.cpp:34: error: 'prexlit' was not declared in this scope
bombagas.cpp:34: error: expected `;' before "endl"
bombagas.cpp: In function `float despacha(float)':
bombagas.cpp:38: error: 'litros' was not declared in this scope
bombagas.cpp:39: error: 'tot' was not declared in this scope
bombagas.cpp:39: error: 'prexlit' was not declared in this scope
bombagas.cpp: In function `int main(int, char**)':
bombagas.cpp:58: error: 'automobile' was not declared in this scope
bombagas.cpp:62: error: 'cant' was not declared in this scope
bombagas.cpp:72: error: expected `while' at end of input
bombagas.cpp:72: error: expected `(' at end of input
bombagas.cpp:72: error: expected primary-expression at end of input
bombagas.cpp:72: error: expected `)' at end of input
bombagas.cpp:72: error: expected `;' at end of input
bombagas.cpp:72: error: expected `}' at end of input
I am guessing classes have a different decalration in unix.Any help?