Вы находитесь на странице: 1из 3

Assignment # 2 Q.1 Define a class string that could work as a user defined string type.

Include constructor that will enable us to create an uninitialized string S1 and also initialize an object with a string constant at the time of creation like string S2(Happy Programming). Also include a function that adds two strings to make a third string. Write a complete program to test your program to see that it does the following task:-(a) Create uninitialized Sting object, (b) Create object with string constant (c) Concatenate two string properly (d) Display a desired string object.

Q.2 Describe the importance of destructor. Q.3 A book shop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displayed whether it is available or not. If it is not an appropriate message is displayed. If it is then the system displays the book details and request for the number of copies required. If the requested copies are available the total cost of copies is displayed; otherwise the message Required copies not in stock is displayed. Design a system using a class called books with suitable member function and constructor. Use new operator in constructor to allocate memory space required.

Q.4 Create an array of objects using single and double parameter constructors. To implement this create a class cl and both constructor inside this. In main function initialize both types of objects at the time of creation. Q.5 Illustrate the use of dereferencing operators to access the class members through pointers. To implement this take a class M, x and y as data members. Take two methods. One is to input the value of x and other sum. The sum is a friend function and the object of class M is passed argument in sum. Sum will access the class members through dereferencing operators. Q.6 Overload the function volume() to compute volume of a cube, cylinder, rectangular box and sphere. Q.7 create a class date. Overload the constructor in date to display the date in mm/dd/yyyy, dd/mm/yyyy and mm/yy. Q.8 write a function that creates an array of user given size M using new operator. Include this function in a class vector. Create the object of vector and allocate memory to this object using new and free it using delete.

Q.9 Define a class TravelPlan in C++ with the following descriptions : Private Members: PlanCode of type long Place of type character array (string) Number_of_travellers of type integer Number_of_buses of type integer Public Members: A constructor to assign initial values of Plan Code as 1001, Place as Agra, Number_of_travellers as 5, Number_of_buses as 1 A function NewPlan( ) which allows user to enter PlanCode, Place and Number_of_travellers. Also, assign the value of Number_of_buses as per the following conditions : Number_of_travellers Number_of_buses Less than 20 1 Equal to or more than 20 and less than 40 2 Equal to 40 or more than 40 3 A function ShowPlan( ) to display the content of all the data members on screen.

Q.10 write a program in c++ to print the front page of your assignment. It will display the content as SHARDA UNIVERSITY DEPARTMENT OF CSE ASSIGNMENT # 2 SUBJECT :OOPS IF ROLL IS EVEN THEN CIPHER TEXT OF YOUR NAME AND NEXT NAME IN SEQUENCE [ USING CAESER CIPHER] ELSE USING RAIL FENCE CIPHER. YOUR NAME ROLL NO. CLASS/TERM/SECTION

Вам также может понравиться