In this program, although I use Ignore(1000,’\n’); why it does not show the title for tape.
In fact, I don’t understand very well about Ignore(); what is the meaning of 1000 in that function?
#include<iostream.h>
class Publication
{
char title[20];
float price;
public:
void putdata()
{
cout<<"\nEnter title:";
cin.getline(title,20);
cin.ignore(1000,'\n');
cout<<"\nEnter price:";
cin>>price;
}
void getdata()
{
cout<<"\nTitle:"<<title;
cout<<"\nPrice:"<<price;
}
};
class Book:public Publication
{
int pgcount;
public:
void putdata()
{
Publication::putdata();
cout<<"\nEnter page count";
cin>>pgcount;
}
void getdata()
{
Publication::getdata();
cout<<"\nPage Count:"<<pgcount;
}
};
class Tape:public Publication
{
float ptime;
public:
void putdata()
{
Publication::putdata();
cout<<"\nEnter playing time:";
cin>>ptime;
}
void getdata()
{
Publication::getdata();
cout<<"\nPlaying time:"<<ptime;
}
};
int main()
{
Book b1;
Tape t1;
b1.putdata();
t1.putdata();
b1.getdata();
t1.getdata();
return 0;
}