Lab 2

You might also like

You are on page 1of 1

Lab -2

Basics of class, ::, namespace, constructor, compilation

1. Implement private and public members in a class.

2. Define a class Complex with variables real and imaginary along with
following:
(a) void setComplex (float, float) to initialize object values.
(b) Void displayComplex() to show the complex number
(c) Complex sum (Complex) to add two complex objects and return the
complex object.
(d) Also try to use pointer object variables and arrow operators.

3. Implement scope resolution operator : : for the following uses:


(a) Class functions defined outside the class
(b) Access a global variable with same name as a local variable
(c) Access a static variables
(d) Use inbuilt libraries (cin cout with scope resolution operator)

4. Create a code to implement the namespace and use similar variables and
functions defined in different code sections.

5. Implement constructor and destructor in a class and a structure.

6. Are you able to understand the difference between struct and class in C++.
Discuss it with your instructor and fellow students.

7. Discuss the following definitions with your lab instructor (a) compiler (b)
interpreter (c) compile time error (d) run time error (e) syntax versus semantic
bug (f) procedural oriented programming (pop) versus object oriented
programming (oop)

You might also like