M
MC felon
getline isn't working.....
what's wrong with this code?
#include <iostream>
#include <string>
#include <conio2.h> // ignore this.. my old habits
class base
{
int x,y;
std::string str;
public:
base() {std::cout<<"I'm the constructor of class
base\n"<<std::endl;}
void setdata(int p,int h)
{
x=p;
y=h;
}
void draw()
{
gotoxy(x,y);
std::cout<<"$\n"<<std::endl;
}
void clear()
{
clrscr();
}
void tryagain()
{
using std::cout;
using std::cin;
int main();
cout<<"would you like to try again?\n"<<std::endl;
getline(cin,str);
if(str == "yes" || str == "y")
{
clrscr();
main();
}
else { exit(0); }
}
};
int main()
{
int p,h;
base b;
base* bt;
bt = &b;
std::cin>>p;
std::cin>>h;
bt -> clear();
bt -> setdata(p,h);
bt -> draw();
bt -> tryagain();
return 0;
}
when i finish with the drawing, it says, "would you like to try again?"
and then exits (without waiting
for my reply).
HELP!
what's wrong with this code?
#include <iostream>
#include <string>
#include <conio2.h> // ignore this.. my old habits
class base
{
int x,y;
std::string str;
public:
base() {std::cout<<"I'm the constructor of class
base\n"<<std::endl;}
void setdata(int p,int h)
{
x=p;
y=h;
}
void draw()
{
gotoxy(x,y);
std::cout<<"$\n"<<std::endl;
}
void clear()
{
clrscr();
}
void tryagain()
{
using std::cout;
using std::cin;
int main();
cout<<"would you like to try again?\n"<<std::endl;
getline(cin,str);
if(str == "yes" || str == "y")
{
clrscr();
main();
}
else { exit(0); }
}
};
int main()
{
int p,h;
base b;
base* bt;
bt = &b;
std::cin>>p;
std::cin>>h;
bt -> clear();
bt -> setdata(p,h);
bt -> draw();
bt -> tryagain();
return 0;
}
when i finish with the drawing, it says, "would you like to try again?"
and then exits (without waiting
for my reply).
HELP!