Questions: 11 448

Answers by our Experts: 10 707

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Write a program that has a class Train with data members seats_first_class, seats_second_class

and seats_ac_2tier and member functions to set and display data. Derive a class Reservation that has

data members booked_first_class, booked_second_class and booked_ac_2tier and functions to book

and cancel tickets and display status.


Define a class Student with data members as rollno and name. Derive a class Fees from student

that has a data member fees and functions to submit fees and generate receipt. Derive another class

Result from Student that displays the marks and grade obtained by the student. Write a program that

extends the class Result so that the final result of the Student is evaluated based on the marks obtained

in tests, activities and sports.


Consider the following inheritance hierarchy: (4) class A{ protected: int x, y; public: int z; }; class B: private A{ private: int a, b, c; public: }; Int main(){ Aobja; void set(int x, int y, int z, int a, int b, int c); B objb; } a) How many data members does B have? Write their names. b) How many of B’s data members are visible in B? Write down their names. c) Which members of B are accessible in main()? How will they be accessed? d) If the protected Access specifier in A is changed to public, then how many members of B will be accessed in main() and how? e) Define the function set() without changing its signature as given above. f) Write a default constructor for the class B that does not have an empty parameter list. g) If the data members of A become private, then how they be initialized? h) Add a static data member in class B. Can we use this pointer with static members? If yes how?


Write a program to print the following details  Assign and print the ID of each employee, (1+1+1.5+1.5)  Phone number and Address of two staff members having names "ali" and "asif" respectively by creating two objects of the class 'Employee'.  throw an exception in case the phone number of employee is inserted in float , double or char value.  throw an exception in case the ID of an employee is inserted in float , double or char value.


Create a class template for a class named GeneralStack that holds (3)

 A single data member as an array named stack of size 50 to store certain elements 

 Three member functions i.e. push(type) to add elements in the Stack, pop() to remove elements from the 

stack, and currentStatus() to check whether the array is filled or not. (A filled array is an array that has non￾zero value at all of its indexes). 

In the main() function, create three objects with different data types of class GeneralStack and test the 

functionality of member functions for various values of data members for these objects.



You have been developing a small commercial Software for numeric operations. You are working on the calculation of areas and volume of different shapes. Based on your software complete these tasks:

a)     Create a function template named as shape() that accepts three arguments in such a way that first and second will be the dimension like base and height and the third will be the name of the shape. The shape() function displays the dimension values and the area of the shape. The function returns the area to the calling program; the area is the same data type as the parameter. [Note: Design a main program such that, it input the values of only those shapes whose area is computable on the bases of base and height only]

b)     Create another function template named as show_master()that accepts two arguments. The first is index and the second argument is an array of 10 values. The show_master() function will returns the specified index value.



Create a class called InputData. It has two private data members data_a and data_b. Set the

values of these two data members by using two public functions get_a() and get_b(). Derive a class

called Arith_Unit from InputData. It contains the functions add(),sub(), mul(),div() to perform

arithmetic operations on data_a and data_b. Derive a class Logic_Unit from InputData. It

contains the functions and(), or() and xor() to perform logical operations on data_a and data_b.

Finally derive a class called ALUnit from Arith_Unit and Logic_Unit classes. It has to perform

arithmetic and logical operations according to the given codes. Choose code 0 to code 6 to perform

the said seven operations. Write sample program to test the ALU class.


Assuming we have following variables and values:

int a=5, b=10, c=15, x, y, z;

Write the values of a, b and c variables in file by using formatted file I/O and then read data accordingly from file and assign it to x, y and z variables. Just create objects of relevant classes, there is no need to write entire main function.



Answer the following short questions. Your answer should be precise.

a)     Can we declare base class constructor or destructor as virtual if yes then why we want to do?

b)    How we can declare a class as abstract and why we need abstract classes? 

Why we cannot able to create objects of abstract classes give reasonable justification of that.     


Write output of given code segments and explain it logically, answer without explanation will be awarded zero marks. 

#include<iostream>

using namespace std;

 

class Base

{

public:

    virtual void show() { cout<<" In Base \n"; }

};

 

class Derived: public Base

{

public:

    void show() { cout<<"In Derived \n"; }

};

 

int main(void)

{

    Base *bp, b;

    Derived d;

    bp = &d;

    bp->show();

    bp = &b;

    bp->show();

    return 0;

}


LATEST TUTORIALS
APPROVED BY CLIENTS