answersLogoWhite

0

#include<conio.h>

#include<iostream.h>

class base

{

protected:

int age;

char name[10];

public:

void input()

{

cout<<endl<<"Enter The Name ";

cin>>name;

cout<<endl<<"Enter The Age ";

cin>>age;

}

void display()

{

cout<<endl<<"Name is..."<<name;

cout<<endl<<"Age is..."<<age;

}

};

class derive:public base

{

private:

public:

void accept()

{

cout<<endl<<"Enter The Address ";

cin>>name;

}

void dis()

{

cout<<endl<<"Address is.."<<name;

}

};

void main()

{

clrscr();

derive obj;

obj.input();

obj.display();

obj.accept();

obj.dis();

getch();

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Write a c plus plus programme to illustrate single inheritance?

struct A {}; // base class struct B : A {} // derived class (single inheritance).


Demonstrate single inheritance in C plus plus?

struct base1 { // ... }; struct base2 { // ... }; struct derived1 : public base1 // single inheritance { // ... }; struct derived2 : public base1, public base2 // multiple inheritance { // ... };


Type of inheritances in c plus plus?

Single, multiple, multi-level, hierarchical and hybrid/virtual inheritance. Single inheritance applies when one class inherits from just one base class. Multiple inheritance applies when one class inherits from two or more base classes. Multi-level inheritance applies to a class that inherits from at least one base class that is itself derived from another base class. Hierarchical inheritance applies to a base class that is inherited by two or more separate derived classes. Hybrid inheritance combines multiple inheritance, multi-level inheritance and hierarchical inheritance. That is, where A is a common base class of derived classes B and C, and B and C are both base classes of derived class D. Hybrid inheritance is often used with virtual inheritance where B and C inherit from A virtually rather than directly. In these cases, the virtual base class is instantiated by the most-derived class in the hierarchy, D, and this instance is then shared by both B and C.


Does c plus plus supports hierarchical inheritance?

Yes.


How ploymorphism and inheritance is different from that in Java and c plus plus?

C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick. For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.


Why is multiple inheritance not possible in C?

C is not object-oriented -- you can't even use single inheritance let alone multiple inheritance.


What is single inheritance in c plus plus?

Multiple inheritance occurs when a class is derived directly from two or more base classes. class b1 {}; class b2 {}; class d: public b1, public b2 {}; // multiple inheritance class


Specification forms of inheritance in java?

single level inheritance eg ( class B extends Class A) Multilevel inheritance eg( class C extends class B and class B extends class A) multiple inheritance Class C inherits Class A features as well as Class B featues.This type of inheritance is not allowed in JAVA.


Programme to implement single and multilevel inheritance taking employee as sample base class in c plus plus?

struct employee { }; struct supervisor : employee { // single inheritance -- a supervisor inherits all the public and protected properties of an employee. }; struct manager : supervisor { // multilevel inheritance -- a manager inherits all the public and protected properties of a supervisor (and therefore an employee). };


How many class of Hierarchical Inheritance?

There are 2 main types of Hierarchical Inheritance - Single and Multi Level Class A extends Class B - Single Class A extends Class B which in turn extends Class C - Multi level. Actually there is no limit to the number of levels till which you can inherit classes in multi level inheritance. But it is preferable to keep it at around 3 or 4 for ease of maintenance and understanding.


How can a constructor be invoked at the time of inheritance in C Plus Plus?

It cannot. Inheritance is a compile-time operation. Constructors are invoked at runtime at the point of instantiation.


Is C plus plus a high level language?

Yes, C++ is a high-level language.