Sunteți pe pagina 1din 6

Create a function called amax () that returns the value of the largest element in an array.

The arguments to the function should be the address of the array and its size. Make this function into template so it will work with an array of any numerical type. Write a main () program that applies this function to arrays of various types.

WAP in c++ for addition, subtraction and multiplication of two matrices using templates.

Consider an example of bookshop, which sells books and videotapes. These two classes are inherited from the base class called media. The media class has command data members such as title and publication. The book class has data members for storing number of pages in a book and the tape class has the playing time in a tape .Each class will have member functions such as read() and show().In a base class, these members have to be defined as virtual functions. Write a program, which models the class hierarchy for bookshop and processes objects of these classes using pointers to the base class.

Create a simple shape hierarchy. A base class called shape and derived classes called circle, square and triangle. In the base class write a virtual function draw and override this in derived classes. Consider an example of declaring the examination result. Design three classes: Student, Exam and Result. The Student class has data members such as those representing roll

numbers, names, etc.Create the class Exam by inheriting the Student class. The Exam class adds data members representing the marks scored in six subjects. Derive the Result from the Exam class and its own data members such as total_marks.Write an interactive program to model this relationship. What type of inheritance this model belongs to?

It is required to find out the cost of constructing a house. Create a base class called House. There are two classes called Door and Window available. The House class has members which provide information related to the area of construction, door, windows details etc.It delegates responsibility of computing the cost of doors and Windows to Door and Window classes respectively. In c++ this can be achieved by having instances of the classes Door and Window in the House class. Write an interactive program to model the above relationship.

Create a class MAT of size m*n.Define all possible matrix operations for MAT type objects. Use Operator Overloading.

Write a C++ program to perform String operations = Equality == String Copy + Concatenation << To display a string >> To reverse a string Use Operator Overloading.

Define two classes to store distance. One of the classes should store distance in centimeters and meters and other should store distance in feets and inches. Read two distances, one for each class and compute sum or difference between them as per the user's choice. Display answer in the unit provided by user. Use friend function, function overloading, default values, constructors etc.

Create a Text class that contains a string object to hold the text of a file. Give it two constructors: a default constructor and a constructor that takes a string argument that is the name of the file to open. When the second constructor is used, open the file and read the contents into the string member object. Add a member function contents( ) to return the string so (for example) it can be printed. In main( ), open a file using Text and print the contents.

Create a Message class with a constructor that takes a single string with a default value. Create a private member string, and in the constructor simply assign the argument string to your internal string. Create two overloaded member functions called print( ): one that takes no arguments and simply prints the message stored in the object, and one that takes a string argument, which it prints in addition to the internal message. Does it make sense to use this approach instead of the one used for the constructor?

Create a class named weather report that holds a daily weather report with data members day_of_month, hightemp, lowtemp,amount_rain and amount_snow. The constructor initializes the fields with default values: 99 for day_of_month, 999 for hightemp,-999 for lowtemp and 0 for amount_rain and amount_snow. Include a function that prompts the user and sets values for each field so that you can override the default values. Write a program that creates a monthly report.

Develop an object oriented program in C++ to create a database of the personnel information system containing the following information: Name, Date of Birth, Blood group, Height, Weight, Insurance Policy number, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz constructor, default constructor, copy constructor, destructor,static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete.

Design a Class Complex with data members for real and imaginary part. Provide default and parameterized constructors. Write a program to perform arithmetic operations of two complex numbers using operator overloading (using either member functions or friend functions).

Design a base class with name, date of birth, blood group and another base class consisting of the data members such as height and weight. Design one more base class consisting of the insurance policy number and contact address. The derived class contains the data members telephone numbers and driving license number. Write a menu driven program to carry out the following things: i) Build a master table ii) Display Delete entry iii) Modify

Design a base class consisting of the data members such as name of the student, roll number and subject. The derived class consists of the data members subject code, internal assessment and university examination marks. Construct a virtual base class for the item name of the student and roll number. The program should have the facilities. i)Build a master table ii) List a table iii) Insert a new entry iv) Delete old entry v) Edit an entry vi) Search for a record

Create a class named Television that has data members to hold the model number and the screen size in inches, and the price. Member functions include overloaded insertion and extraction operators. If more than four digits are entered for the model, if the screen size is smaller than 12 or greater than 70 inches, or if the price is negative or over $5000 then throw an integer. Write a main() function that instantiates a television object, allows user to enter data and displays the data members .If an exception is caught ,replace all the data member values with zero values

An Educational institution wishes to maintain a database of its employees. The database is divided into a number of classes whose hierarchical relationships are shown below. Write a menu driven program to carry out the following things: i) Build a master table ii) Display iii) Insert a new entry iv) Delete entry

Staff Code, Name

Teacher Subject, Publication

Officer Grade

Typist Speed

Regular

Casual Daily Wages

The class master derives information from both account and admin classes which in turn derive information from the class person. Define all four classes and write a program to create, update and display the information contained in master objects. Person Name, code

Account Pay Master Name, Code Exp, pay

Admin Experience

Create a base class called shape. Use this class to store two double type Values that could be used to compute the area of figures. Derive two specific classes called triangle and rectangle from the base shape. Add to the base class, a member function get_data() to initializes base class data members and another member function display_area() to compute and display the area of figures. Make display_area() as a virtual function.

S-ar putea să vă placă și