Exp.1 Write any C++ program to demonstrate Encapsulation feature of an Object Oriented
Programming.

(Aim:- The main aim of this experiment is providing security to data from outside code and identifying
objects from given problem statement.)

Objective: Student will get practical awareness about encapsulation concept.

Example programs:

   a. Define a Calculator class. Create Calculators and invoke them for input from cin, from
      command-line arguments, and for strings in the program. Allow output to be delivered to a
      variety of targets similar to the way input can be obtained from a variety of sources.
   b. Define a Student class which contains a student’s confidential information. Note:- Analyze and
      consider more attributes and two member functions for reading and updating.
   c. Define a Fruit class which contains all information of a fruit and member function. Note:-
      Analyze and consider more attributes and two member functions for reading and updating.

Exp.2 Write any C++ program to demonstrate “Encapsulation of member functions and data members
with its default values and its initialization when an object was created” concept.

(Aim:- The main aim of this experiment is providing security to data from outside code and identifying
objects from given problem statement and its initialization. )

Objective: Student will get practical awareness about encapsulation, constructors and default
constructors concepts.

Example Programs:

       a. Define a Baby class and identify attributes of a baby and initialize them when a baby was
          born.
       b. Define a Book class and identify attributes of a book and initialize them when a book was
          manufactured.
       c. Define a Vehicle class and identify its attributes and initialize them when a vehicle was
          manufactured.
       d. Define a class String that could work as a user-defined string type. Include constructors that
          will enable us to create an uninitialized string
                        String s1; // string with length 0.
               and also to initialize an object with a string constant at the time of creation like
                        String s2(“hello”);
               Include a function that adds two strings to make a third string. Note that the statement
                        s2 = s1;
               will be perfectly reasonable expression to copy one string to another.
               Write a complete program to test your class to see that it does the following tasks:
                        i.       Creates uninitialized string objects.
ii.     Creates objects with string constants.
                          iii.    Concatenates two strings properly.
                          iv.     Displays a desired string object.



Exp.3 Write any C++ programs to demonstrate multilevel inheritance concept of an object oriented
programming.

(Aim:- The main aim of this experiment is reusability of code and getting idea about classifying objects ,
identifying specific and generic objects and creating hierarchy between objects ).

Objective: Student will get awareness to create relationship between objects.

Example Programs:-

    a. Assume that a bank maintains two kinds of accounts for customers, one called as savings
        account and the other as current account. The savings account provides compound interest and
        withdrawal facilities but no cheque book facility. The current account provides cheque book
        facility but no interest. Current account holders should maintain a minimum balance and if the
        balance falls below this level, a service charge is imposed.
       Create a class account that stores customer name, account number and type of account. From
       this derive the classes cur_acct and sav_acct to make them more specific to their requirements.
       Include necessary member functions in order to achieve the following tasks:

    i.          Accept deposit from a customer and update the balance.
    ii.        Display the balance
    iii.       Compute and deposit interest.
    iv.        Permit withdrawal and update the balance.
    v.         Check for the minimum balance, impose penalty, necessary, and update the balance.
           Don’t use constructors to initialize the class members.

    b. implement above program using constructors to initialize the class members.

    c. An educational institution wishes to maintain a database of its employees.




Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented
programming.

(Aim:- The main aim of this experiment is reusability of code and getting idea about classifying objects ,
identifying specific and generic objects and creating hierarchy between objects ).
Objective: Student will get awareness to create relationship between objects.

Example Programs:-




Exp.5 Write any C++ programs to demonstrate hierarchal inheritance concept of an object oriented
programming.

(Aim:- The main aim of this experiment is reusability of code and getting idea about classifying objects ,
identifying specific and generic objects and creating hierarchy between objects ).

Objective: Student will get awareness to create relationship between objects.



Example Programs:-




Exp.6   Write any C++ programs to demonstrate access controls of an object oriented programming.

( Aim:- The main aim of this experiment is, “identifying which members are private members, which
members are public members, which members are constant members which members are static
members ext…”)

Objective: Student will get awareness in the usage of access specifies, friend functions, virtual functions
in implementation.

Example Programs:-

M.tech oops through_c++_labmanual1 (1)

  • 1.
    Exp.1 Write anyC++ program to demonstrate Encapsulation feature of an Object Oriented Programming. (Aim:- The main aim of this experiment is providing security to data from outside code and identifying objects from given problem statement.) Objective: Student will get practical awareness about encapsulation concept. Example programs: a. Define a Calculator class. Create Calculators and invoke them for input from cin, from command-line arguments, and for strings in the program. Allow output to be delivered to a variety of targets similar to the way input can be obtained from a variety of sources. b. Define a Student class which contains a student’s confidential information. Note:- Analyze and consider more attributes and two member functions for reading and updating. c. Define a Fruit class which contains all information of a fruit and member function. Note:- Analyze and consider more attributes and two member functions for reading and updating. Exp.2 Write any C++ program to demonstrate “Encapsulation of member functions and data members with its default values and its initialization when an object was created” concept. (Aim:- The main aim of this experiment is providing security to data from outside code and identifying objects from given problem statement and its initialization. ) Objective: Student will get practical awareness about encapsulation, constructors and default constructors concepts. Example Programs: a. Define a Baby class and identify attributes of a baby and initialize them when a baby was born. b. Define a Book class and identify attributes of a book and initialize them when a book was manufactured. c. Define a Vehicle class and identify its attributes and initialize them when a vehicle was manufactured. d. Define a class String that could work as a user-defined string type. Include constructors that will enable us to create an uninitialized string String s1; // string with length 0. and also to initialize an object with a string constant at the time of creation like String s2(“hello”); Include a function that adds two strings to make a third string. Note that the statement s2 = s1; will be perfectly reasonable expression to copy one string to another. Write a complete program to test your class to see that it does the following tasks: i. Creates uninitialized string objects.
  • 2.
    ii. Creates objects with string constants. iii. Concatenates two strings properly. iv. Displays a desired string object. Exp.3 Write any C++ programs to demonstrate multilevel inheritance concept of an object oriented programming. (Aim:- The main aim of this experiment is reusability of code and getting idea about classifying objects , identifying specific and generic objects and creating hierarchy between objects ). Objective: Student will get awareness to create relationship between objects. Example Programs:- a. Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should maintain a minimum balance and if the balance falls below this level, a service charge is imposed. Create a class account that stores customer name, account number and type of account. From this derive the classes cur_acct and sav_acct to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks: i. Accept deposit from a customer and update the balance. ii. Display the balance iii. Compute and deposit interest. iv. Permit withdrawal and update the balance. v. Check for the minimum balance, impose penalty, necessary, and update the balance. Don’t use constructors to initialize the class members. b. implement above program using constructors to initialize the class members. c. An educational institution wishes to maintain a database of its employees. Exp.4 Write any C++ programs to demonstrate multiple inheritance concept of an object oriented programming. (Aim:- The main aim of this experiment is reusability of code and getting idea about classifying objects , identifying specific and generic objects and creating hierarchy between objects ).
  • 3.
    Objective: Student willget awareness to create relationship between objects. Example Programs:- Exp.5 Write any C++ programs to demonstrate hierarchal inheritance concept of an object oriented programming. (Aim:- The main aim of this experiment is reusability of code and getting idea about classifying objects , identifying specific and generic objects and creating hierarchy between objects ). Objective: Student will get awareness to create relationship between objects. Example Programs:- Exp.6 Write any C++ programs to demonstrate access controls of an object oriented programming. ( Aim:- The main aim of this experiment is, “identifying which members are private members, which members are public members, which members are constant members which members are static members ext…”) Objective: Student will get awareness in the usage of access specifies, friend functions, virtual functions in implementation. Example Programs:-