0% found this document useful (0 votes)
113 views

C++ Basics

The document provides an overview of key C++ concepts including: 1. Classes, objects, member functions, and arrays are discussed with an example employee class. 2. Important features of OOP such as encapsulation, inheritance, and polymorphism are covered at a high level. 3. Key C++ concepts like function overloading, templates, exception handling, and file I/O are defined and examples provided to demonstrate their usage.

Uploaded by

Darshan .B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views

C++ Basics

The document provides an overview of key C++ concepts including: 1. Classes, objects, member functions, and arrays are discussed with an example employee class. 2. Important features of OOP such as encapsulation, inheritance, and polymorphism are covered at a high level. 3. Key C++ concepts like function overloading, templates, exception handling, and file I/O are defined and examples provided to demonstrate their usage.

Uploaded by

Darshan .B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

C++ basics

1. Develop a class called Employee that has emp_code and emp_name as data members.
Member function get_data() to accept the data and member function display () to display
the employee details. Write a main() function to create EMP, an array of employee
objects. Accept and display the details for n employees. (5)
2. Discuss the important features of object oriented programming.
3. Define Inline function.
4. Explain the following (5 Marks)
Class objects (b) scope resolution operator (c) data hiding (d) access members
5. Create a distance class with feet and inches as data members , member function to input
distance , member function to output distance , member function to add two distance
objects . Develop a C++ program for the given specification.
6. Discuss the important features of object oriented programming.
7. List the characteristics of a friend function. Write a C++ program to add two complex
numbers using friend function.
8. Define function overloading. Develop a C++ program to define three overloaded
functions to swap two integers, swap two floats and swap two doubles.
9. Demonstrate a C++ program for passing objects to functions and returning objects.
10. Explain the following with an example (i) Inline functions (ii) scope resolution operator
11. Define function overloading. Write a C++ program to implement function overloading in
order to compute power(m,n) where
(i) m is double and n is int
(ii) m and n are int
12. Write a program to design a class with static member function named show_count ()
which has the property of displaying the number of objects created by the class.
13. Write a program to illustrate Default function arguments.
14. Define Inline function along with syntax. Mention its advantages and disadvantages.
15. Write a program using class to process shopping list for a departmental store.
The list include details such as the code no, item name and price of each item.
Add the member functions to add the items, delete the items, to the list and to print the
total value of the order.
Constructors and Destructors :
1. Illustrate the various types of constructors with suitable examples.

Operator overloading :
1. Discuss the general rules for operator overloading. (5)
2. Develop a C++ program to overload new and delete operators for a specific class. (5)

3. Create a class called TIME that has integer data members for hours, minutes and seconds.
Include two constructors where one constructor should initialize this data to zero and another
should initialize it to fixed values. Implement the following :

(i) A member function to add two TIME objects using operator overloading

(ii) A member function to display time in HH:MM:SS format

(iii) A main function to create two TIME objects, add them and display the result in
HH:MM:SS format.

3. Develop a program to implement a class MATRIX of size M X N. Overload the


operator ‘*’ to multiply two matrix objects. Write the display function to print the
original matrix and resultant matrix.

Inheritance
1. Analyze in what order are class constructors and desttructors called when a derived class
object is created. Illustrate with an example for a multilevel inheritance. (5 Marks )

2. Create a base class called 'SHAPE' having Two data members of type double Member
function get-data( ) to initialize base class data members, Pure virtual member
function display-area( ) to compute and display the area of the geometrical object.
Derive two specific classes 'TRIANGLE' and 'RECTANGLE' from the base class. Using
these three classes design a C++ program that will accept dimension of a triangle or
rectangle interactively and display the area.

3. Discuss the ambiguities that arise in multiple inheritance. How can they be addressed. (5
Marks)
4. Discuss the ambiguities that arise in multiple inheritance. How can they be addressed. (5
Marks)
5. Create a class called Account. The Account class is inherited by Savings_Account and
Current_Account. Implement a C++ program to calculate simple interest for
Savings_Account only. The rate of interest is 4% per annum.
6. Discuss Pure virtual function with an example.
7. Differentiate between compile time and run time polymorphism.
8. Develop a C++ program illustrating how the constructors are implemented and the order
in which they are called when the classes are inherited. Use three classes named alpha,
beta and gamma such that alpha, beta are base classes and gamma is derived class
inheriting alpha and beta.
9. Explain the visibility of the base class members for the access specifiers : Private,
Protected and Public which creating the derived classes.
10. Implement a Class called STUDENT with data members USN, Name and Age.
Using inheritance, create the classes UGSTUDENT and PGSTUDENT having fields
as Semester, Fees and Stipend. Enter the data for at least 5 students. Find the semester-
wise average age for all UG and PG students separately.
11. Infer the ambiguities that arise in multiple inheritance. Illustrate how they can be
resolved. (5 marks)
12. Develop three classes : STUDENT, EXAM AND RESULT. The STUDENT class has
data members such as roll_no and name. Create a class EXAM by inheriting the
STUDENT class. The EXAM class has data members representing the marks scored in
six subjects. Derive the RESULT class from the EXAM class having total marks as its
data member. Develop a C++ program to model this relationship.

Templates :

1. Define Template. Write a C++ program to find the minimum of elements using function
templates.

2. Define Function template for finding the minimum value contained in an array. Write main
function to find the minimum value of integer array and minimum value of floating point
numbers in a n array

3. Describe function templates in C++

Exception Handling :

1. Describe exception handling with try throw and catch constructs in C++.-(6 Marks)
Files:
1. Write a C++ program, to create a structure with Car_Model, Color and Price to a file
and print the details from the file on to the console using file operations.-(8 Marks)

2. Write a program that creates a text file by reading the data for the students from the
terminal. The data of each student consists of Roll number, name and marks. Again open
the same file to display the student information. –(8 marks)

3. Develop a C++ program to copy the contents of one file to another. (6 Marks)

4. Explain open() and close() in a file (6 Marks)

5. Write a C++ program to create a structure with name, USN, and CGPA to a file and print
the details from the file onto the console using File operations.

6. Explain the following Input output functions in files.


get()
Getline()
Read()
Write()

Standard templates :
1. Illustrate vectors, lists and maps in STL. (10 marks)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy