By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

what is the error in this multiple inheritance cpp program?

P: 1
#include<iostream.h>
#include<conio.h>
class doctor
{
char name[20],dp[20],speci[20];
public:
void read();
void print();
};
class patient
{
char name[20],disease[20];
int age;
public:
void read();
void print();
};
class ip:public doctor,public patient
{
int admino,bedno;
public:
void read();
void print();
};

void doctor::read()
{
cout<<"Name of dr:\n";
cin>>name;
cout<<"Department:\n";

cin>>dp;
cout<<"Specialist:\n";
cin>>speci;
}
void doctor::print()
{

cout<<"Dr name:\t"<<name;
cout<<"\ndepartment name:\t"<<dp;
cout<<"\nspecialist in:\t"<<speci;
}
void patient::read()
{
cout<<"Patient name:\n";
cin>>name;
cout<<"age:\n";
cin>>age;
cout<<"Disease:\n";
cin>>disease;
}
void patient::print()
{
cout<<"\nPatient Name:\t"<<name;
cout<<"\nage:\t"<<age;
cout<<"\ndisease:\t"<<disease;
void ip::read()
{
cout<<" IP PATIENT\n";
cout<<" \/\/\/\/\/\n";
doctor::read();
patient::read();
cout<<"\nEnter the admission date:";
cin>>admino;
cout<<"\nEnter the bed no:";
cin>>bedno;
}
void ip::print()
{
cout<<"\n||||||||||||||||||||||\n";
cout<<"\nDetails of IP Patient\n";
doctor::print();
patient::print();
cout<<"\nadmin no:\n"<<admino;
cout<<"\nbed no:\n"<<bedno;
}
void main()
{
clrscr();
ip obj1;
obj1.read();
obj1.print();
getch();
};
Jul 15 '15 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
patient::print() is missing a closing brace.

This literal cout << " \/\/\/\/\/\n"; has the escape sequence character \ so the compiler thinks / is an escape character, which it is not. Use \\ rather than \ to force the \ as a character. Then the / will be OK:

Expand|Select|Wrap|Line Numbers
  1. cout << "   \\/\\/\\/\\/\\/\n";
Jul 15 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.