473,699 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is the error in this multiple inheritance cpp program?

1 New Member
#include<iostre am.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<<"Departme nt:\n";

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

cout<<"Dr name:\t"<<name;
cout<<"\ndepart ment name:\t"<<dp;
cout<<"\nspecia list 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<<"\nPatien t Name:\t"<<name;
cout<<"\nage:\t "<<age;
cout<<"\ndiseas e:\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<<"\nDetail s 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
1 1527
weaknessforcats
9,208 Recognized Expert Moderator Expert
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

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

Similar topics

2
4333
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
5
2669
by: Mark | last post by:
When declaring a class that uses multiple inheritance, does the order used when listing the inheritance matter? I'm finding with my compiler (gcc 3.2.2) that my program seg faults when destructing if the order is "wrong". In my program I use an STL vector to store objects of type Server *. Server is an abstract base class. When exiting my program I iterate through the vector and call delete on all my Server objects. One of the...
3
582
by: Tony Johansson | last post by:
Hello experts! I have a small program that is using multiple inheritance. There are 4 classes involved I get 4 compile error that I can't figure out why. It's this row which is located in the main program see below that is causing these compile errors. cout << p->getName() << endl; Here is the first compile error the other might be a consequesce of the first one.
2
3462
by: Tony Johansson | last post by:
Hello Experts! I have been playing around a bit with this multiple inheritance and I wonder why do I get a compile error if I remove the virtual keyvord from the declaration of the Student class and the Employee class. I have removed all kind of data from all classes. The compile error occur when I instansiate Person* p = new TeachingAssistent; The error I get is c:\Documents and
5
2109
by: Tony Johansson | last post by:
Hello Experts! I just play around just to try to understand this about multiple inheritance. You have all the class definition below and at the bottom you have the main program. So here I use multiple inheritance. One top class called MBase and below this we have D1 and D2 on the same level.
0
985
by: blackdevil1979 | last post by:
Hello, > "In COM, multiple inheritance between interfaces is not supported. However, by using the derived members capability, multiple inheritance can be simulated."..MSDN Library I have created an object which involve a datagrid. But when I create a form and try to use the object, I found that some of the property exists for a datagrid does not show in the usercontrol in the form, for example
5
2820
by: Thomas Girod | last post by:
Hi. I think I'm missing something about multiple inheritance in python. I've got this code. class Foo: def __init__(self): self.x = "defined by foo" self.foo = None
7
3734
by: Adam Nielsen | last post by:
Hi everyone, I'm having some trouble getting the correct chain of constructors to be called when creating an object at the bottom of a hierarchy. Have a look at the code below - the inheritance goes like this: Shape | +-- Ellipse | +-- Circle
5
1566
by: Hypnotik | last post by:
Hello everyone. I'm working on multiple inheritance program. I have a pretty specific problem that I'm not sure how to overcome. I'm going to try to explain this as simple as possible. There is a person class which has some info. A student class, which inherits the person info, and has some additional info. A worker class which has it's own info, and inherits the person info. A student_worker class which inherits from all of the above classes....
0
9180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7755
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6536
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2351
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2012
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.