Showing posts from June, 2012

Consider a class Complex Class Complex { float real; float imaginary; Public: //methods; }; Overload operator ‘+’ to add two objects of that class use parameterized constructor for accepting values of complex numbers.

#include<iostream.h> #include<conio.h> class Complex {   flo…

Design two base classes Personnel (name, address, email-id, birth date) and Academic (marks in tenth, marks in twelth, class obtained). Derive a class Bio-data from both these classes. Write a C++ program to prepare a bio-data of a student having Personnel and Academic information.

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

Consider a class Matrix Class Matrix { int a[3][3]; Public: //methods; }; Let m1 and m2 are two matrices. Find out m3=m1+m2 (use operator overloading).

#include<iostream.h> #include<conio.h> class Matrix {   int …

Write class declarations and member function definitions for a C++ base class to represent an Employee (emp-code, name). Derive two classes as Fulltime (daily rate, number of days, salary) and Parttime (number of working hours, hourly rate, salary). Write a menu driven program to: 1. Accept the details of ‘n’ employees and calculate the salary. 2. Display the details of ‘n’ employees. 3. Search a given Employee.

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

Consider a class Matrix Class Matrix { int a[3][3]; Public: //methods; }; Overload the – (Unary) should negate the numbers stored in the object.

#include<iostream.h> #include<conio.h> class Matrix { int a[…

In a bank, different customers having saving account. Some customers may have taken a loan from the bank. So bank always maintains information about bank depositors and borrowers. Design a Base class Customer (name, phone-number).Derive a class Depositor(accno, balance) from Customer. Again derive a class Borrower (loan-no, loan-amt) from Depositor. Write necessary member functions to read and display the details of ‘n’ customers.

#include<iostream.h> #include<conio.h> class Customer { prot…

Consider a class Matrix Class Matrix { int a[3][3]; Public: //methods; }; Let m1 and m2 are two matrices. Find out m3=m1*m2(use operator overloading).

#include<iostream.h> #include<conio.h> class Matrix {  int a…

Create a base class Roundshape(radius). Derive three different shapes as Circle, Sphere and cylinder(height) from Roundshape. Class Roundshape { Protected : float radius; Public: static float Pi; Roundshape(float); //default argument virtual float area( )=0; }; Write a C++ program to calculate area of Circle, Sphere and cylinder.

#include<iostream.h> #include<conio.h> class Roundshape { pr…

Consider the following class hierarchy. Create a base class Employee(empcode, empname). Derive the classes Manager(designation, clubdues), Scientist(deptname, publications) and Labourer from Employee class. Write a C++ menu driven program 1. to accept the details of ‘n’ employees 2. to display the information 3. to display all the scientist from “Chemistry Department”.

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

Consider the following class Class String { char *ptr; int length ; public: //member function definitions. }; Overload the unary operator! For the string class as a member function so that its return “true”. If the string pointed as by ptr is empty, “false” otherwise write a main() to test this function. Write other necessary functions including constructor (s) and destructor(s).

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

Design a class which contain static data member and member function show() which displays number of times display operation is performed irrespective of the object responsible for display using static data member.

#include<iostream.h> #include<conio.h> class student { stat…

Create a class string which contains a character pointer. Write a C++ program to overload following operators: 1. < to compare two strings (using new operator) 2. != to check equality two Strings.

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

Write a C++ program to find volume of cube, cylinder and rectangle using function overloading.

#include<iostream.h> #include<conio.h> int volume(int); double…

Write a C++ program using class with function replace (char* str, char c1, char c2) every occurrence of c1 in str should be replaced with c2 and return number of replacement it makes use default value for char c2 use class.

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

Create a class Time which contains: - hours - minutes - second Write a C++ program using operator overloading for the following: 1. = = to check whether two Times are same or not. 2. >> to accept the time. 3. << to display the time.

#include<iostream.h> #include<conio.h> class Time { int hour…

Create a class vector that contains series of n numbers. Perform the Pre-Increment and Post- Decrement operations on a vector object using operator overloading.(Use friend Function).

#include<iostream0.h> #include<conio.h> int size; class vector…

Create a class Array which contains - int *ptr - int n Write a menu driven program : - to Accept an array from user - to display it. - to add two arrays using operator overloading. - to subtract two arrays using operator overloading.

#include<iostream.h> #include<conio.h> class array { int  *p…

Write a menu driven C++ program using class to perform all arithmetic operation (+,-,*,/) (use inline function).

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

Write a C++ program to define function power to raise a number m to a power n the function takes a double value for m. and integer value for n and return the result correctly use a default value of 2 for n to make the function calculate squares when this argument is omitted.

#include<iostream.h> #include<conio.h> double power(double,int=…

. Consider the following class Person { char Name [20]; char Addr [30];float Salary; int Property; //in sq. foot area float tax_amount; Public: // methods };

#include<iostream.h> #include<conio.h> class person { char n…

Write a C++ program using class to overload the operator unary increment ++ for an integer number.

#include<iostream.h> #include<conio.h> class Float { float a…

Create a C++ class for student having following members. - Rollno - Name - Number of subjects - Marks of each subject (Number of subjects varies for each student) Write a parameterized constructor which initializes rollno, name & Number of subjects and creates the array of marks dynamically. Display the details of all students with percentage and class obtained.

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

Write a C++ program using class to overload the operator unary decrement -- for an integer number.

#include<iostream.h> #include<conio.h> class Float { float a…

Create a class FDAccount containing members as: - Fdno - Name - Amt - Interest rate - Maturity amt - Number of months Use parameterized constructor to set appropriate details, where interest rate should be default argument. Calculate maturity amt using interest rate and display all the details.

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

Create a class student containing data members: - Rollno - name -marks1, marks2, marks3 Write necessary member functions: 1. to accept details of all students 2. to display details of one student 3. to display details of all students (Use Function overloading).

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

Consider the following class mystring Class mystring { char str [100]; Public: // methods }; Overload operator + to concatenate two strings such as string1+string2=string3.

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

Create a class time that contains hours, minute and seconds as data members. Write the member functions: 1. to add two object of type time, passed as arguments . 2. to convert a time into total number of seconds. 3. to display the time into format like: 29-11-2009.

#include<iostream.h> #include<conio.h> class time { int hour…

Load More That is All