0% found this document useful (0 votes)
27 views2 pages

Xii Compsc HW

1. A class defines the form and behavior of objects, while an object is an instance of a class. Inline functions should be small and avoid recursion for performance. Copy constructors are invoked when an object is returned by value or assigned to another object, copying the values. 2. The questions ask about classes, functions, constructors, destructors, and OOP concepts like inheritance and polymorphism. Code snippets are provided to demonstrate these concepts. 3. An Election class is defined with private data like name, party, votes for each candidate and public functions to accept input, display winner, and return winner details. A main function would declare objects and call class functions.

Uploaded by

deemalhotra73
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Xii Compsc HW

1. A class defines the form and behavior of objects, while an object is an instance of a class. Inline functions should be small and avoid recursion for performance. Copy constructors are invoked when an object is returned by value or assigned to another object, copying the values. 2. The questions ask about classes, functions, constructors, destructors, and OOP concepts like inheritance and polymorphism. Code snippets are provided to demonstrate these concepts. 3. An Election class is defined with private data like name, party, votes for each candidate and public functions to accept input, display winner, and return winner details. A main function would declare objects and call class functions.

Uploaded by

deemalhotra73
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Define : class , object


2. What is inline function?What points should you take care while making a
function inline?
3. What do you understand by Copy constructor? Specify two instances when
copy constructor is invoked?
4. Two overloaded functions are defined as:
void choice (char, char); -(1)
void choice (int , float); -(2)
Which of functions will be called by following calls.
choice(‘A’, 10);
choice (10.5, 10.5);

5) Name the header files to which following standard functions belong:


i) random() ii) gotoxy() iii) getc() iv) strcmpi()
6) Declare class height containing data members to store height of a person in feet
and inches.
Add suitable member functions to:
 Read height of a person
 Display height
 Find and return taller out of two person’s height given as input to functions.
 Convert height in cms.

7) Answer the questions a and b after going through the code :

class exam
{
int mark ;
char sub [ 30 ];
public :
exam ( ) Function 1
{
marks = 0 ;
strcpy ( sub , “ computer “ );
}
exam ( char s [ ] ) Function 2
{
marks = 0 ;
strcpy ( sub , s );
}

exam ( int m ) Function 3


{
marks = m ;
strcpy( sub , “ c ++ “ );
}
exam ( char s [ ] , int m ) Function 4
{
marks = m ;
strcpy ( sub , s );
}
}

a. Write statements to execute all four functions (1)

b. Can we over load a destructor . (1/2)


c. What concept of OOPS is demonstrated by the four functions (1/2)

8) Define a class ELECTION with the following specifications . Write a suitable main ( ) function
also to declare 3 objects of ELECTION type and find the winner and display the details .
(3)

Private members :
Data : candidate_name , party , vote_received
Public members :
Functions : enterdetails ( ) – to input data
Display ( ) – to display the details of the winner
Winner ( ) – To return the details of the winner trough the object
after comparing the votes received by three candidates .

9) Give any two characteristics of constructors and destructors.


10) Explain default constructor ans constructor with default values.

You might also like