mhatre.ganesh20

Object Oriented Programming Practical 21

Object Oriented Programming Practical 21 Question 1 Define a class parent in which use read function, define another class child use same read function. Display the data of both the read function on output screen using virtual function. virtual.cpp C #include<iostream.h> #include<conio.h> class Parent { public: virtual void read() { cout << "Parent class read

Object Oriented Programming Practical 21 Read More »

Object Oriented Programming Practical 20

Object Oriented Programming Practical 20 Question 1 Write a C++ program to add two complex numbers using operator overloading by a friend function. complex.cpp C #include<iostream.h> #include<conio.h> class complex { int real,img; public: void accept() { cout<<"nEnter real part of complex number: "; cin>>real; cout<<"nEnter imaginary part of complex number: "; cin>>img; } void display()

Object Oriented Programming Practical 20 Read More »

Object Oriented Programming Practical 19

Object Oriented Programming Practical 19 Question 1 Overload the unary operator –(minus) using member function and friend function unary.cpp C #include<iostream.h> #include<conio.h> class unary { float num; public: void accept() { cout<<"nEnter number: "; cin>>num; } void display() { cout<<"Number= "<<num<<endl; } unary operator–() { num=num-1; } }; void main() { clrscr(); unary u; u.accept();

Object Oriented Programming Practical 19 Read More »

Object Oriented Programming Practical 18

Object Oriented Programming Practical 18 Question 1 Write a C++ Program to interchange the values of two int , float and char using function overloading. swap.cpp C #include<iostream.h> #include<conio.h> void swap(int a,int b) { int temp=a; a=b; b=temp; cout<<"nAfter swapping number1 is "<<a<<" and number2 is "<<b<<endl; } void swap(float a,float b) { float temp=a;

Object Oriented Programming Practical 18 Read More »

Object Oriented Programming Practical 17

Object Oriented Programming Practical 17 Question 1 Write a C++ program declare a class “polygon” having data members width and height. Derive classes “rectangle” and “triangle” from “polygon” having area() as a member function. Calculate area of triangle and rectangle using pointer to derived class object. polygon.cpp C #include<iostream.h> #include<conio.h> class polygon { public: int

Object Oriented Programming Practical 17 Read More »

Object Oriented Programming Practical 16

Object Oriented Programming Practical 16 Question 1 Write a C++ program to declare a class “Book” containing data members book_name, auther_name, and price . Accept this information for one object of the class using pointer to that object. book.cpp C #include<iostream.h> #include<stdio.h> #include<conio.h> class book { public: int price; char book_name[50],author_name[50]; void accept() { cout<<"nEnter

Object Oriented Programming Practical 16 Read More »

Object Oriented Programming Practical 15

Object Oriented Programming Practical 15 Question 1 Write a program which show the use of constructor in derived class. car.cpp C #include<iostream.h> #include<conio.h> #include<string.h> class car { char car_type[100]; public: car(char c_type[30]) { strcpy(car_type,c_type); } void display() { cout<<"nCar c_type: "<<car_type; } }; class brand:public car { float speed; char brand_name[50]; public: brand(float sp,char name[30],char

Object Oriented Programming Practical 15 Read More »

Object Oriented Programming Practical 14

Object Oriented Programming Practical 14 Question 1 Write a C++ program to implement the concept of virtual base class for following figure. student.cpp C #include<iostream.h> #include<conio.h> class student { char name[50]; public: void accept() { cout<<"nEnter name of student: "; cin>>name; } void display() { cout<<"nName of student: "<<name; } }; class test:virtual public student

Object Oriented Programming Practical 14 Read More »

Object Oriented Programming Practical 13

Object Oriented Programming Practical 13 Question 1 Write a C++ program to implement the following inheritance. Accept and display data for one programmer and one manager. Make display function virtual. employee.cpp C #include<iostream.h> #include<conio.h> class employee { int empcode,empid; public: void accept() { cout<<"nEnter id of employee: "; cin>>empid; cout<<"nEnter code of employee: "; cin>>empcode;

Object Oriented Programming Practical 13 Read More »

Object Oriented Programming Practical 12

Object Oriented Programming Practical 12 Question 1 Write a Program to get the average marks of six subjects using the Multiple Inheritance. average.cpp C #include<iostream.h> #include<conio.h> class SubjectGroup1 { public: int sub1, sub2, sub3; void getGroup1() { cout << "Enter marks for Subject 1: "; cin >> sub1; cout << "Enter marks for Subject 2:

Object Oriented Programming Practical 12 Read More »