what is the error in this multiple inheritance cpp program?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Goldy T Joseph
    New Member
    • Jul 2015
    • 1

    what is the error in this multiple inheritance cpp program?

    #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();
    };
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    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:

    Code:
    cout << "   \\/\\/\\/\\/\\/\n";

    Comment

    Working...