answersLogoWhite

0

In the OOP the single inheritance concept is to access the parent/super class properties into the derived class.

Coding :

#include<iostream.h>

#include<conio.h>

#include<conio.h>

class test {

char name[20], add[20];

int roll;

public:void getdata(){

cout<<"Enter your name, address and roll number";

cin.getline(name,20);

cin.getline(add,20);

cin>>roll; }

void putdata() {

cout<<"Your name address and roll no. is"<<name<<add<<roll;

};

class test1:public test {

int phone,fees;

public: void get() {

test::getdata(); {

cout<<"Enter your phone number & fees";

cin>>phone>>fees;}}

void put(){

test::putdata();{

cout<<"Your phone number and fees are"<<phone<<fees;}}

void main(){

clrscr();

test1 t ;

t.get();

t.put();

getch(); }

User Avatar

Wiki User

14y 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 { // ... };


How many classes can we write in a single c plus plus program?

Its limited only by available memory.


Does c plus plus supports hierarchical inheritance?

Yes.


Why is multiple inheritance not possible in C?

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


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.


Can you program games with c plus plus?

Yes, you can program games with C++.


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


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 to restart c plus plus program?

Exit the program and relaunch it.


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.


Lint is a compiler b a interactive debugger c a cinterpreter d a tool for analysing c plus plus program?

d a tool for analysing c plus plus program