Hi all, I have a real problem here.
In my first program, the window just closes without showing the result??
here's the code, i
Code:
// programmet klipp.cpp
#include <iostream.h>
#include <stdlib.h> // för exit
#include <string.h>
// deklaration av klassen aktie
class aktie {
char foretag[25];
int aktier, varde, totalt;
void tot(){totalt=aktier*varde;}
public:
void ordna (const char*fo,int x,int pris);
void visa();
}; // klass aktie
void aktie::ordna (const char* fo, int x, int pris){
strcpy (foretag, fo);
aktier= x;
varde = pris;
tot();
}
void aktie::visa() {
cout<< " Företag: " << foretag
<< " Aktier: " << aktier << '\n'
<< " Värde i kr: " << varde
<< " Totalt: " << totalt <<'\n';
} // slut
int main(void) {
char namn[25];
int antal, pris;
aktie aktie1;
cout<< " Ange aktie: ",
cin>> namn;
cout<< " Ange antal: ";
cin>> antal;
cout<< " Ange pris: ";
cin>> pris;
aktie1.ordna(namn, antal, pris);
aktie1.visa();
return 0;
}
what am I doing wrong?
I'm using Bloodshed Dev C++ compile rif that helps.