Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented programming.

Ads
 

Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented programming.

(Aim:- The main aim of this experiment is reusability of code and getting idea about classifying objects , identifying specific and generic objects and creating hierarchy between objects ). Objective: Student will get awareness to create relationship between objects.

View Answers

October 31, 2012 at 10:12 AM

Here is a code that demonstrates you the concept of multiple inheritance.

#include<iostream.h>
#include<conio.h>

class student
{
    protected:
       int rno,m1,m2;
    public:
                void get()
              {
                            cout<<"Enter the Roll no :";
                            cin>>rno;
                            cout<<"Enter the two marks   :";
                            cin>>m1>>m2;
              }
};
class sports
{
    protected:
       int sm;                   
    public:
                void getsm()
              {
                 cout<<"\nEnter the sports mark :";
                 cin>>sm;

              }
};
class statement:public student,public sports
{
    int tot,avg;
    public:
    void display()
              {
                 tot=(m1+m2+sm);
                 avg=tot/3;
                 cout<<"\n\n\tRoll No    : "<<rno<<"\n\tTotal      : "<<tot;
               cout<<"\n\tAverage    : "<<avg;
              }
};
void main()
{
   clrscr();
   statement obj;
   obj.get();
   obj.getsm();
   obj.display();
   getch();
}

Ads









Related Tutorials/Questions & Answers:
Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented programming.
Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented programming.  (Aim:- The main aim of this experiment...; Here is a code that demonstrates you the concept of multiple inheritance
Object Oriented Programming in Java
OOPS acronym for Object Oriented Programming is a model or concept that works... of a class. For a language to be an Object Oriented Programming Language, it must... concept are used to create programs based on the real world. By the name OOPS
Advertisements
object oriented programming protocol
object oriented programming protocol  What is object oriented programming protocol? Is it different from objective c protocol programming?? Thanks
Object Oriented Programming in PHP
Object Oriented Programming in PHP  Hi, Which version of PHP supports OOPS. How can I learn Object Oriented Programming in PHP? Thanks
An Overview of Java      Java is a programming language      Java is Object Oriented Programming
; Java as a programming language Java is an Object oriented... are in pure C code, not C++. The function prototypes are in an object-oriented form...; Java as an Object Oriented Language In this section, we will discuss the OOPs
Difference between Java and C++
that supports procedural programming and object oriented programming. C++ fully... and application programming. C++ has added support for object-oriented programming...++. C++ supports procedural, functional and object oriented programming
Is Java object oriented?
Is Java object oriented?  Hi, Is Java object oriented? Thanks   Hi, Java is object oriented programming language. It is supports OPPS concepts: Object Class Inheritance Polymorphism Abstraction Encapsulation All
Concept of Inheritance in Java
Concept of Inheritance in Java Concept of Inheritance in Java is considered one of the important features of Object Oriented Programming. Inheritance... class from parent class. Let's understand the concept of inheritance in Java
Object Oriented
Object Oriented  C++ is Purely object oriented or not .Then why java called purely object oriented
Java using Netbeans Object Oriented Programming
Java using Netbeans Object Oriented Programming   I am trying to make a program that uses a main class and a separate class with one public method and one private method. The main method in the main class asks the user for 2
Multiple Inheritance
class so java any how do multiple inheritance? Can you please explain...Multiple Inheritance  All are saying java doesn't support multiple inheritance but by default Object class is super class for all the user defined
Inheritance in Java
Inheritance, one of the important concepts of Object Oriented Programming... class. Multilevel Inheritance: Multiple Inheritance is when a subclass is derived... for it's just above (parent) class. Multilevel inheritance can go up to any number
Learning Java Programming for Beginners
Java is an Object Oriented Programming Language that was developed by Sun Microsystems. It is based on C, C++ programming language but a tad better.... Programmer can post any problem and ask any doubt. What is Programming
java is pure object oriented
are not object 2)It does not support operator overloading multiple inheritance. 3...java is pure object oriented  java is pure object oriented or not.? reason.?   Java is not pure object oriented language because
Inheritance in Java with example
Here we are going to discuss Inheritance in Java with a simple example. Inheritance is a Object Oriented Programming concepts, which allows to extend... of more than one class into a single class. Multiple inheritance in Java can
Is Java a pure object oriented language?
programming language but not purely a object oriented language. In OOPs programming... through the class and object creation. For more object oriented programming language...Is Java a pure object oriented language?   Hi, Is Java a pure
Does Java support multiple Inheritance?
Does Java support multiple Inheritance?  Hi, I am beginner in Java and trying to implement multiple inheritance in Java. But could not find any example. Does Java support multiple Inheritance? Thanks   Hi, Good
Does Java support multiple Inheritance?
Does Java support multiple Inheritance?  Hi, I am beginner in Java and trying to implement multiple inheritance in Java. But could not find any example. Does Java support multiple Inheritance? Thanks   Hi, Good
Does Java support multiple Inheritance?
Does Java support multiple Inheritance?  Hi, I am beginner in Java and trying to implement multiple inheritance in Java. But could not find any example. Does Java support multiple Inheritance? Thanks   Hi, Good
multiple inheritance
multiple inheritance  why java doesn't support multiple inheritance? we can achieve this by using interface but not with classes? what is the main reason that java community implemented like
Multiple Inheritance
Multiple Inheritance  Why Java Doesn't have Multiple Inheritance It is Advantage or Disadvantage.........   Hi Friend, When we extends... and inconsistencies Java does not support Multiple Inheritance. Thanks
Difference between C++ and Java
Java and C++ are Object Oriented Programming (OOPs) language. Java... programming and extends the C programming language. Java supports network computing... the class In C++ programming can be done without making objects
Java Inheritance Concept.
Java Inheritance Concept.  Yesterday i got confused with following question in an aptitude exam. Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit
Java Object
Java Object         Object is the basic entity of object oriented programming language. Object.../java-object-oriented-language.shtml  
programming concept
programming concept  Write a program that allows the user to input a total dollar amount for an online shopping order and computes and outputs the shipping cost based on the following schedule
What is attribute oriented programming?
What is attribute oriented programming?  Hi, What is attribute oriented programming? Thanks
java : object oriented
java : object oriented   (a) Write a class named CarRental... and their relationship. (c) Write an application named UseCarRental that prompts... for above two classes and their relationship. (c) Write an application named
c++ programs
c++ programs  i want the syntax for the following programs according to c++ pattern. 1.sum of multiples of an integer upto 10 2.2/4+4/6+6/8+8/10+.....n/n+2 3.1!/1+2!/2+3!/3+4!/4+...n!/n i just want the main logic as i m nt
c++ programs
c++ programs  Write a program with the following (a) A function to read two double type numbers from keyboard (b) A function to calculate the division of these two numbers (c) A try block to throw an exception when a wrong type
c++ programs
c++ programs  Write a program with the following (a) A function to read two double type numbers from keyboard (b) A function to calculate the division of these two numbers (c) A try block to throw an exception when a wrong type
Java7 : OOPs Concepts
JAVA7 : OOPs Concept In this section we will discuss concept of Object oriented programming. Object Oriented Programming : Object Oriented Programming, better termed as OOPs is a paradigm where everything is represented as an object

Ads