C++ Programming Practice Exercises

Class and Objects

  1. Create a class Student to store his personal details like age, name, height and weight and create member functions to accept and show the data of objects

Constructors

  1. Define constructor with any default values for class Student to initialise all its data members.
  2. Define constructor for class Student to accept different values to initialise data members of each object at the time of declaration.
  3. Define constructor for class Student to accept user input for the data members

Overloading

  1. combine all the constructor definitions of above exercises into one and create different objects in main function to check their working
  2. Create a class Shape with more than one definition for his member function area.  Write three different definitions for area() so that it can calculate area of circle, square and rectangle based on the input values.

Inheritance

  1. Create a class Man with data age, height and weight and member functions getManData() and showManData().  Derive another class Student from public derivation of class Man.  Student class has data members as course, duration, fees.  create main function to check the inheritance accessibility.

You cannot copy content of this page