Assignment & Lab
Assignment & Lab
Assignment & Lab
COMP 116
Object Oriented Programming
Assignment Set #0
1. What is Structured Programming? How does Object Oriented Programming differ from it?
2. What is namespace and what is its use?
Assignment Set #1
1. List the features of OOP. Explain each in detail.
2. What is the difference between structure and class? What are the advantages of using
class over structure?
3. What do the keywords public, protected and private mean? What is their significance?
4. Define inline function with an example. What is the advantage of using inline functions?
5. Define function overloading with an example. In what kind of scenario would you
overload a function?
Assignment Set #2
1. Differentiate between constructor and destructor. Describe the different types of
constructors with suitable examples.
2. What is friend function? Illustrate its use in overloading binary operators.
3. What is overriding function? How does it differ from function overloading?
4. What sort of ambiguity can be resolved by defining virtual base classes?
5. What are static types? What are its uses? Illustrate using code.
Assignment Set #3
1. What is Inheritance? Why is it important? Briefly describe the different types of
Inheritance with suitable examples?
2. What do you mean by Polymorphism? Illustrate with an example how pure virtual
function can be implemented.
3. What is Composition? How does it differ from Inheritance? Illustrate with an example.
4. What do you mean by Function Template and Class Template? Illustrate with examples.
5. Why do you need to handle exception? What is the mechanism in C++ to handle it?
Assignment Set #4
Assignment 4 will be declared in class.
[Deadlines for submission of all assignments and labs will be declared in the class. Late
submission will not be entertained. Students are expected to compile all assignments and lab
sheets into a file and bring it during their practical finals and viva.]
Lab Work #0
1. WAP to take 2 numbers input from the user and display its product.
2. Write a function to add 2 numbers.
3. Write an array with capacity with 7 and display the largest number.
4. WAP to read a string and display it.
Lab Work #1
1. WAP which contain a class “Car” with attributes: name, gear, speed. It should have the
functions to gear_up, gear_down, show_gear and show_speed. Attributes should be of
data type int and string only. Write a driven program as well.
2. Define a class called "Rectangle" with following attributes: length and breadth of data
type integer. Also include the following member functions:
void setSize(int length, int breadth); // this function should set the value of length
and breadth of the Rectangle.
int getArea( ); // this function should return the area of the rectangle.
int getPerimeter( ); // this function should return the perimeter of the rectangle.
// formula to calculate: area = length * breadth.
// formula to calculate: perimeter = 2 * (length + breadth).
Write a driven program as well.
Lab Work #2
class Complex
Private:
int x;
int y;
public:
Complex( );
Complex( int x, int y);
Class Shape
public side_one :double
public side_two :double
public Shape() :Constructor
public Shape(double, double) :Constructor
public set_data(double, double) :void
public virtual display_area() :void
SYLLABUS: http://ku.edu.np/cse/LEVEL100/comp%20116.pdf
TEXT BOOKS:
1. John R. Hubbard, Theory and Problems of Programming with C++, 2/e, McGraw-Hill.
2. H. M. Deitel, “C++ How to Program”, D and D.
3. Friedman and Koffman, “Problem Solving, Abstraction and Design using C++ , 5/e,
Addison-Wesley.
4. E. Balagurusamy, “Object Oriented Programming in C++, 6/e” Tata McGraw-Hill
Education
ONLINE REFERENCES
1. http://www.cplusplus.com/doc/tutorial/
2. http://www.tutorialspoint.com/cplusplus/index.htm
3. https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83