So I have this code but I don't know why two lines in the code are spiking read. This two lines are marked by comments below:
#include <iostream>
#include<stdio.h>
using namespace std;
class publication{
char title[20];
int price;
public:
void getdata(){
cout<< "Enter the price of the book";
cin>>price;
cout<< "Enter the title"; #this line 1st
gets(title); #this is not running
}
void putdata(){
cout<<price;
puts(title);
}
};
class Tape:public publication{
float play;
public:
void getdata(){
cout<< "Enter play"; #this line 2nd
cin>>play;
}
void putdata(){
cout<<endl<<play;
}
};
int main()
{
publication p;
p.getdata();
p.putdata();
Tape t;
t.getdata();
t.putdata();
book b;
b.getdata();
b.putdata();
}
Now I am unable to understand why line 16 and 47 i skipped. I have checked the syntax it's all good. There are no errors in this program. I use codeblocks and gnu gcc compiler for c++. This is the image
In this image as you can see the two lines have auto-compiled without taking the input for the title. Some lines of code are removed which were not relevant to the problem.