Video 24

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Unix_C++_SYS_Mini_Project_1

Exercises:

1. Built a class hierarchy, minimum of 3 classes, (say Country->State->District-


>My_Home) create an object of any intermediate class and try to access the public
member of the object created using pointers of all the class type. Observe the output
and do appropriate cast (if required) to make the member accessible using pointer of
all type in a hierarchy. [Do check for both virtual and non-virtual functions.]

2. From the previous example try explicit type cast (dynamic_cast or static_cast) Use
typeid operator to get the type of object pointed by pointer after each casting.

3. Create another branch of hierarchy (say Country->Union_Territories-


>Friends_Home ) using the same base class from the previous example and try to
access the public member of a class of one branch using the pointer of class from
another branch. [You may use cast operator to convert the type to the appropriate
type]. [Check if you are able to do so].

4. Create two namespaces with a common variable and few distinct variables, Try to
assign value to the variables from the main function, and print the value of all the
variables from both the namespaces. [ Try to create namespace local to any block, i.e
inside a class as member or as a local namespace for any function even the main();]

You might also like