0% found this document useful (0 votes)
3 views1 page

Exercise

The document contains an exercise from Lecture 05 that includes true or false statements regarding static data members and functions in classes. It also poses questions about when to use static members, friendship between classes, and requires implementations of operator functions for a Complex class and matrix addition. The exercise aims to test understanding of object-oriented programming concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Exercise

The document contains an exercise from Lecture 05 that includes true or false statements regarding static data members and functions in classes. It also poses questions about when to use static members, friendship between classes, and requires implementations of operator functions for a Complex class and matrix addition. The exercise aims to test understanding of object-oriented programming concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Exercise – Lecture 05

[A] State whether the following statements are True or False:

(a) Static data members are shared amongst multiple objects.

(b) Static member functions can access only static data members.

(c) Static data member must be declared inside the class but defined
outside it.

(d) Static member function can be accessed using the syntax


classname::functionname( ).

[B] Answer the following:

(a) When will you make a data member of a class as static?

(b) When will you want to make class Sample friend of an Example
class?

(c) When will you make function fun( ) friend of a class Sample?

(d) Implement += and -= operator functions in Complex class.

(e) Implement + operator function to add two 3 x 3 matrices.

You might also like