Mail Archives: djgpp/1997/02/09/01:58:57
ok guys, i need some help really bad. i have a strange problem w/ my
prog.
//heres the warnings on compliing
D:\PROGS\cppic>gxx -Wall -c ampm_air.cpp
ampm_air.cpp: In method `void airtime::set()':
ampm_air.cpp:20: warning: initializing non-const `int &' with `Day' will
use a t
emporary
d:/djgpp/lang/cxx/iostream.h:196: warning: in passing argument 1 of
`istream::op
erator >>(int &)'
ampm_air.cpp:20: warning: initializing non-const `int &' with `Day' will
use a t
emporary
d:/djgpp/lang/cxx/iostream.h:196: warning: in passing argument 1 of
`istream::op
erator >>(int &)'
ampm_air.cpp: At top level:
ampm_air.cpp:32: warning: return type for `main' changed to integer type
gcc.exe: -lgpp: linker input file unused since linking not done
gcc.exe: -lstdcx: linker input file unused since linking not done
gcc.exe: -lm: linker input file unused since linking not done
//end warnings
//no linking errors or warnings R issued
//here's the prog
// arrayair.cpp
// create an array of airtime objects
#include <iostream.h>
#include <iomanip.h>
enum Day { am, pm };
class airtime
{
private:
int minutes, hours;
Day half;
public:
void set()
{
char dummy;
cout << "Enter time (ie. 4:45am): ";
cin >> hours >> dummy >> minutes >> half;
// i think the previous line is the trouble maker
hours += minutes / 60;
minutes %= 60;
hours %= 12;
}
void display()
{
cout << hours << ':' << setfill('O') << setw(2) << minutes << half;
}
};
void main()
{
airtime at[20];
int n=0;
char choice;
do
{
cout << "Airtime " << n << ". ";
at[n++].set();
cout << "Do another(Y/N) ";
cin >> choice;
} while(choice != 'n');
for(int j=0; j<n; ++j)
{
cout << "\nAirtime " << j << " = ";
at[j].display();
}
}
// end prog
it seems like it is working fine but at the input it just
crashes(badly) leaving a huge list of gibberish and this
Control-Break Pressed at eip=00012f26
eax=00000000 ebx=00000021 ecx=00000000 edx=00000000 esi=00004000
edi=0005e73c
ebp=0005e718 esp=0005e70c program=D:\PROGS\CPPIC\AMPM_AIR.EXE
cs: sel=00a7 base=82b03000 limit=0006ffff
ds: sel=00af base=82b03000 limit=0006ffff
es: sel=00bf base=82b03000 limit=0006ffff
fs: sel=0087 base=00017f50 limit=0000ffff
gs: sel=00c7 base=00000000 limit=ffffffff
ss: sel=00af base=82b03000 limit=0006ffff
Call frame traceback EIPs:
0x00012f26
0x00010e2e
0x00012ac6
0x0000f187
0x000076fe
0x00003464
0x000015ce
0x00000006
i no this is a pain but please i need help, it's driving me looney.
much thanks N advance
Pyro
- Raw text -