Hi I am learning C++ and i coded this program but it isnt working as it was supposed to..
#include<iostream.h>
using namespace std;
class furniture
{
protected:
int color,width, height;
};
class bookshelf : public furniture
{
private:
int no_of_shelves;
public:
int accept() {
cout<<"enter color"<<endl;
cin>>color;
cout<<"enter width"<<endl;
cin>>width;
cout<<"enter height"<<endl;
cin>>height;
cout<<"enter no of shelves"<<endl;
cin>>no_of_shelves;
}
int display() {
cout<<"color is "<<color<<endl;
cout<<"width is "<<width<<endl;
cout<<"hegiht is "<<height<<endl;
cout<<" no of shelevs is "<<no_of_shelves<<endl;
}
};
int main() {
bookshelf b;
b.accept();
b.display();
}
output is as follows:
enter color
aa
enter width
enter height
enter no of shelves
color is 0
width is 0
hegiht is -1073744596
no of shelevs is -1881141193
it just asks for color and rest of it is a mess..! :( can u tell me what's goign wrong ? thanks!