14
Object Oriented Programming Using C++ (16MCA22) 1. GENERAL INFORMATION: Academic Year: 2017 Semester: II Title Code Duration (hrs) Object Oriented Programming using C++ 16MCA22 Lectures 48 Hrs Seminars 2 Hrs Total 50 Hrs 2. PRE REQUIREMENT STATEMENT: Student should know the basics of Internet , HTML and some knowledge about OOPs concept. 3. COURSE DESCRIPTION: Object oriented programming with C++ provides information about how to develop projects in c++ and gives information about classes, objects, data encapsulation inheritance, reusability, overriding ,operator overloading functions etc..It comprises of several functions like string functions eg.Strcat to perform string concatenation and strlen functions and also contains inheritance concept that helps us to create base and derived classes. using files we can also read and write information about a person to the file or from the file. Object oriented programming with C++ also contains exception handling concepts with try and catch block which gives overall knowledge about handling exceptions PESIT- Bangalore South Campus Hosur Road (1km Before Electronic city) Bangalore 560 100 Department of MCA COURSE INFORMATION SHEET

PESIT- Bangalore South Campus Hosur Road (1km …pesitsouth.pes.edu/pdf/2017/mca/16MCA22.pdf · Chapter Cumulative 1 CHAPTER 1: Program Introduction ... K R Venugopal,Rajkumar Buyya,T

Embed Size (px)

Citation preview

Object Oriented Programming Using C++ (16MCA22)

1. GENERAL INFORMATION:

Academic Year: 2017 Semester: II

Title Code Duration (hrs)

Object Oriented Programming

using C++ 16MCA22

Lectures 48 Hrs

Seminars 2 Hrs

Total 50 Hrs

2. PRE REQUIREMENT STATEMENT:

Student should know the basics of Internet , HTML and some knowledge about OOPs concept.

3. COURSE DESCRIPTION:

Object oriented programming with C++

provides information about how to develop projects in c++ and gives information about classes, objects, data

encapsulation inheritance, reusability, overriding ,operator overloading functions etc..It comprises of several functions

like string functions eg.Strcat to perform string concatenation and strlen functions and also contains inheritance concept

that helps us to create base and derived classes. using files we can also read and write information about a person to the

file or from the file. Object oriented programming with C++ also contains exception handling concepts with try and

catch block which gives overall knowledge about handling exceptions

PESIT- Bangalore South Campus Hosur Road (1km Before Electronic city)

Bangalore – 560 100

Department of MCA

COURSE INFORMATION SHEET

4. LEARNING OUTCOMES

After completion of the subject Object Oriented Programming Using C++ the student will be able to

Identify and create classes and objects and they are able to use the concepts like data encapsulation,

polymorphism, data abstraction

Understand functions and parameter passing

Static and dynamic binding of data will be made possible and Use multiple inheritance to share the

data among different classes.

Organize the data in the memory using containers(STL entities)

Be able to design, implement, and test relatively large C++ programs.

Discover errors in a C++ program and describe how to fix them and to critique a C++ program and describe ways to

improve it

analyze a problem and construct a C++ program that solves it and also Gain knowledge in doing projects using C++.

5. FACULTY DETAILS:

Faculty Name : Mrs.Jayanthi.R

Department : MCA

Room Number: 504

Phone Number: 8951112398

Mail-id :[email protected]

Contact Hours : College Hours

Consultation Time: By E-Mail

6. VENUE AND HOURS/WEEK:

All lectures will normally be held in 500,501 and 506, 5th Floor.

Lecture Hours/week: 4Hrs

All the laboratory sessions will be held in Room 500 & 506, V Floor.

Laboratory Hours/week: 2Hrs

7. MODULE MAP:

Class

#

Chapter #

Topics to be covered

% of portions covered

Reference

Chapter

Cumulative

1

CHAPTER

1: Introduction

The Origins of C++ , What Is Object-

Oriented Programming?

,Encapsulation ,Polymorphism , Inheritance.

Some C++ Fundamentals ,A Sample C++

Program

2

A Closer Look at the I/O Operators,

Declaring Local Variables ,No Default to

int, The bool Data Type , Old-Style vs.

Modern C++ , The New C++ Headers ,

Namespaces, Working with an Old Compiler

15.0

20.0

3 Introducing C++ Classes, Function

Overloading, Operator Overloading

,Inheritance Constructors and Destructors ,The

C++ Keywords, The General Form of a C++

Program.

4 Classes and Objects: Classes,

Structures and Classes Are Related, Unions

and Classes Are Related

5 Anonymous

Unions, Friend Functions, Friend Classes,

Inline Functions, Defining Inline Functions

Within a Class Parameterized Constructors

6

Constructors with One Parameter: A

Special Case Static Class Members

7 Static Data Members ,Static Member

Functions 8 When Constructors and Destructors Are

Executed ,The Scope Resolution Operator

9

Nested Classes, Local Classes,

Passing Objects to Functions

10

Returning Objects

,Object Assignment.

11

CHAPTER

2: Arrays, Pointers,

References, and the

Dynamic Allocation

Operators:

Arrays of

Objects, Creating Initialized vs. Uninitialized

Arrays , Pointers to Objects, Type

Checking C++ Pointers

20.0

40.0

12 The this Pointer, Pointers to Derived Types ,

Pointers to Class

Members , References, Reference Parameters,

Passing References to Objects, ,

Restrictions to References

13 Returning References, Independent

References, References to Derived Types,

Restrictions to References

14

A Matter of Style , C++'s Dynamic Allocation

Operators

,Initializing Allocated Memory ,Allocating

Arrays ,Allocating Objects ,The nothrow

Alternative ,The Placement Form of new 15

The nothrow Alternative ,The Alternative

Placement Form of new

16

Function Overloading, Copy Constructors

Default Arguments: Function Overloading

17 Overloading Constructors,

Overloading a Constructor to Gain Flexibility,

Function

18 Allowing Both Initialized and

Uninitialized Objects Copy Constructors ,

Finding the Address of an Overloaded

19 The overload Anachronism, Default Function

Arguments

20 Default

Arguments vs. Overloading, Function

Overloading and Ambiguity

21

CHAPTER

3:

Operator

Overloading:

Creating a Member Operator Function,

Creating Prefix and

Postfix Forms, of the Increment and

decrement Operators

20.0

60.0

22 Overloading the

Shorthand Operators, Operator Overloading

Restrictions

23

Operator Overloading Using a Friend

Function, Using a Friend to Overload ++ or –

24

Friend Operator

Functions Add Flexibility , Overloading new

and delete, Overloading new and delete

for Arrays

25

Overloading the nothrow Version of new and delete, Overloading Some

Special Operators, Overloading [ ]

26

Overloading ( ), Overloading –>, Overloading

the Comma Operator

27

Inheritances: Base-Class Access Control,

Inheritance and

protected Members, Protected Base-Class

Inheritance

28 Inheriting Multiple Base

Classes, Constructors, Destructors, and

Inheritance

29 When Constructors and

Destructors Are Executed , Passing

Parameters to Base-Class Constructors

30 Granting Access, Virtual Base Classes.

31 CHAPTER 4: Virtual Functions and

Polymorphism:

Virtual Functions, Calling a Virtual Function

Through a Base, Class Reference

15.0

80.0

32

The Virtual Attribute Is Inherited, Virtual

Functions Are Hierarchical

33

Pure Virtual Functions, Abstract Classes,

Using Virtual Functions,

Early vs. Late Binding

34

Templates: Generic Functions, A Function

with Two Generic Types

35

Explicitly Overloading a Generic Function,

Overloading a Function Template, Using

Standard Parameters with Template Functions

36

Generic Function Restrictions ,

Applying Generic Functions, A Generic

Sort, Compacting an Array

37

Generic Classes,

An Example with Two Generic Data Types,

Applying Template Classes: A Generic Array

Class

38

Using Non-Type Arguments with Generic

Classes, Using Default

Arguments with Template Classes, Explicit

Class Specializations, The typename and

export Keywords,

39

The Power of Templates .Exception Handling:

Exception Handling

Fundamentals, Catching Class Types, Using

Multiple catch Statements, Handling Derived-Class Exceptions, Exception Handling

Options, Catching All Exceptions, Restricting

Exceptions, Rethrowing an Exception

40

Understanding terminate( ) and

unexpected( ), Setting the Terminate and

Unexpected Handlers, The

uncaught_exception( ) Function, The

exception and bad_exception Classes

Applying

Exception Handling.

41 CHAPTER

5:

Standard C++ I/O

Classes

Old vs. Modern C++ I/O, C++ Streams, The

C++ Stream

Classes, C++'s Predefined Streams

20.0

100.0

42 Formatted I/O, Formatting Using the ios

Members, Setting the Format Flags, Clearing

Format Flags

43 Overloading << and >>,

Creating Your Own Inserters, Creating Your

Own Extractors, Creating Your Own

Manipulator Functions

44 C++ File I/O: fstream> and the File Classes,

Opening and

Closing a File, Reading and Writing Text Files

45

Unformatted and Binary I/O, Characters vs.

Bytes, put( ) and get( ), read( ) and write( ),

More get( ) Functions,

getline( )

46 Detecting EOF, The ignore( ) Function, peek(

) and putback( ), flush( )

47 Random Access, Obtaining the Current File

Position , I/O Status, Customized I/O and Files

48 STL : An Overview of the STL, Containers,

Algorithms, Iterators

49 Function Objects, The String Class, Vector

Class

50 Lists, Maps

12.RECOMMENDED BOOKS/JOURNALS/WEBSITES

Text Books:

1.Herbert Schildt:The Complete reference C++,4th

Edition,Tata

McGraw Hill,2003.

Reference Books:

1. Stanley B.Lippmann,Josee Lajore:C++ Primer,4th

edition,Pearson

Education,2005.

2. Paul J Deitel,Harvey M Deitel: C++ for Programmeres,Pearson

Education,2005.

3. K R Venugopal,Rajkumar Buyya,T Ravi Shankar,Mastering

C++,Tata McGraw Hill,1999

9 ASSIGNMENTS

The students has to submit 2 assignments, one before first internal and the second one before second

internal exam

Assignment -1

1.Program for linked list,string concatenation and for converting expression from infix into postfix using C++

Assignment -2 2. A mini project to be submitted in the form of assignment using C++

10 THEORY ASSESSMENT

WRITTEN EXAMINATION

Paper Structure

No. Of Questions 5Main Questions No. of questions to be answered 5

Exam date Paper Duration 3 Hrs

Total Marks 80 Pass Marks 40

CONTINUOUS ASSESSMENT

Parameters Weighting (%)

Class Test(s): 5 Marks (10%)

Assignment(s): 5 Marks (10%)

Seminar(s): 5 Marks (10%)

Test(s): 30 Marks (60%)

Overall

Performance:

5 Marks (10%)

Total Marks: 50 Marks

11 QUESTION BANK 1. What is object oriented programming? Explain the features of

OOP. *

2. Differentiate object oriented design and procedure based design.*

3. Explain purpose of including preprocessor directive in c++

program?* 4. Explain the following data types with examples.

5. Pointer types, string types, reference types, the bool type, enumeration types, array types,

complex number types. *

6. Explain const qualifier and volatile qualifier and typedef names. * 7. Differentiate the features of C and C++.

8. Explain new and delete expressions with examples.*

9. Explain different types of type conversions in C++. *

10.List the operators and keywords in C++ .

11. Write the complete Operator and expression evaluation precedence.

12. Write a note on Scope resolution operator “::”. 13. Differentiate how strings are handled in and C++. *

14. How function declaration are different in C++ compared with C?

15. What is a class? How does it accomplish data hiding? *

2. How is a member function of a class defined?

3. Differentiate unions and classes. *

1. Explain different parameter passing ways to functions in C++ with examples. *

2. When will you make a function inline? Why? *

3. Demonstrate pointers to functions with an example. *

4. Write a note on linkage directives. *

5. How command line options are handled using main()? Explain in detail. **

6. Explain global objects and local objects with an example.

7. Write a note on dynamically allocated objects.

8. Explain function overloading and three steps of overload resolution. *

9. Explain overloading a function template.*

10.Demonstrate a generic sort.*

11.Explain different types of passing parameters to functions.*

12. What is the main advantage of passing arguments by reference?

13‘’Explain friend classes and friend functions. *

4. When do we declare a member of a class static? *

5. What are the merits and demerits of using friend functions?

6. What is a constructor? Explain different types of constructors. *

7. Describe the importance of destructors. * 8. How do we invoke a constructor function? *

9. Write a program to demonstrate a. array of objects

b. pointers to objects c. this pointer

*

d. pointers to class members *

e. pointers to derived types * 10. What is operator overloading? Why is it necessary to overload an operator? *

11. What is an operator function? Describe the syntax of an operator function.

12. Write a program to demonstrate operator overloading using friend functions

a. To overload ++ and –- operators *

b. To overload special operators [], ->, and comma (,)

operator.

c. Output operator << and input operator >>. * 1. What is inheritance? Explain with an example. *

2. What are the different forms of inheritance? Give an example for each. *

3. What is a virtual base class? When do we make a class virtual? * 4. What is an abstract class? *

5. Write a program demonstrate

a. The calling a virtual function trough a base class reference b. Pure virtual functions *

6. Explain early and late binding. * 7. How is polymorphism achieved at (a) compile time, and (b)run time? *

8. When do we make a virtual function “pure”? What are the

implications of making a function a pure virtual function? * 9. What is a stream? Describe the features of I/O system supported by

C++. *

10. Explain the architecture of standard header stream files of

C++ compiler. *

11. What are input and output streams? What are the steps involved in using a file in a C++

program? *

12. What is a file mode? Describe the various file mode options available.

13. What is inheritance? Explain with an example. *

14. What are the different forms of inheritance? Give an example for each. *

15. What is a virtual base class? When do we make a class virtual? *

16. What is an abstract class? * 17. Write a program demonstrate

a. The calling a virtual function trough a base class reference b. Pure virtual functions *

18. Explain early and late binding. * 19. How is polymorphism achieved at (a) compile time, and

(b)run time? *

20. When do we make a virtual function “pure”? What are the

implications of making a function a pure virtual function? *

21. What is a stream? Describe the features of I/O system supported by C++. *

22. Explain the architecture of standard header stream files of

C++ compiler. * 23. What are input and output streams? What are the steps involved in using a file in a C++

program?What is a file mode? Describe the various file mode options available.

PREVIOUS QUESTION PAPERS Third Semester M.C.A Degree

Examination January / February 2005

1. (a) Explain the concept of Object Oriented Programming. Bring out the salient features of structured

programming and object oriented programming. 10

(b) What is volatile qualifier? Give an example.

4

(c) Explain how new and delete operators manage memory allocation dynamically.

6

2. (a) Discuss how call by reference methods of passing parameters can be achieved using reference

variables. Illustrate this through a program to find the GCD of two positive integers

8

(b) What are default arguments? Explain with an illustration. State and

explain the rules applying the default arguments. 6

(c) What are friend functions? Why are they used ? Explain with an example.

6 3. (a) Define class and object. With an example, explain the concept of data encapsulation and

accessing of member function. 10

(b) Bring out the differences between C++ structures and C++ classes.

4

(c) Write a program to generate series of Fibonacci numbers using

copy constructor 6

4. (a) What is polymorphism? What are their uses? 4

(b) Write a program to perform multiplication of two complex numbers by overloading * operator.

10

(c) what is virtual base class? Explain with an example the use of virtual base class.

6

5. (a) What is inheritance? Bring out the concept of various types of inheritances.

4

(b) Write c++ program to create a class called STUDENT with the 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

for all UG and PG students separately 10

(c) Write a note on the visibility of member function based on private, public and protected derivations

6 6. (a) What is function template? Explain the purpose of function template with suitable example.

8

(b) Write a program to implement a Bubble sort using function

templates 10

(c) What is template argument deduction

2

7. (a) What are virtual functions? With an example explain the need for virtual function

8

(b) What are early and late binding? Explain with an example.

6

(c) What are manipulators? List the various predefined

manipulators supported by C++ I/O streams.

8. Write short notes on the following: (5 *4 =20 )

i) inline function

ii) Pure virtual functions

iii) use of abstract classes in c++

iv) this pointer with an example

Third Semester M.C.A Degree Examination

July / August 2004 1. a) Explain the concept of object oriented programming Also explain it features.

10

b) What is a volatile qualifier? Give an example

4

c) Explain how new and delete expressions manage memory

allocation dynamically.

6 2. a) What are the advantages of using function? Explain function prototyping and parameter passing

mechanism.

10

b) Write a note on inline functions with illustrations

6

c) Explain the meaning of scope and life time of an object

4

3. a) What if function overloading? Discuss overload resolution.

10

b) Write a c++ program to illustrate a template function for quick sort

and demonstrate sorting of integers and doubles.

10

4. a) Define class and object. With an example explain the concept of data encapsulation and accessing of

member elements

10

b) Explain the concept of constructors and destructors with example.

6

c) Write a note on scope resolution operator.

4 5. a) Write a note on nested classes.

5

b) What are friend functions? Why are they used? Explain with an

example.

10

c) Explain static data members and static member functions.

5

6. a) Explain the following with examples i) implicit ‘this’

pointer.

ii) pointers to class members. 10

b) Write a program to perform addition and multiplication of two complex numbers by overloading +

and * operators. 10

7. a) What is inheritance? Briefly explain the different types of

inheritances. 10

b) Write a note on virtual functions. 6

c) Explain the use of abstract classes in C++. 4

8. a) What are iostreams in C++? Give the stream class hierarchy. 10

b) Write a C++ program to create a class called STRING and implement the following.

Display the results by overloading the

operator << after every operation.

a. STRING S!=”VTU”

b. STRING S2=”BELGAUM”

c. STRING S3=S1+S2

Use copy constructor 10

Third Semester M.C.A Degree Examination

January / February 2004 1. a) Explain the following with Syntax

i)typedef names ii) volatile qualifiers iii) reference types iv) comma operator

10

b) What is object oriented programming? Explain its characteristics.

10 2. a) Define function overloading? Illustrate with an example the various steps involved in function

overloading 10

b) What is an inline function? Write a C++ program with nesting of member functions.

3. a) Define friend functions in C++. Write a C++ program with use of

objects as function arguments. 10

b) Define copy constructor. Write C++ program describing constructor overloading

10

4. a) Explain static members of a class. Write a C++ program to describe them.

10

b) With clear comments write a C++ program to describe this pointer

10

5. a) Define operator overloading. Write a C++ program to illustrate this concept using scalar

multiplication of a vector. 10

b) Define various types of type conversions. 10 6. a) Discuss various types of inheritance. Write a program for multiple inheritance

10

b) Define virtual base class. Write a C++ program to illustrate virtual base classes.

10

7. a) What are iostreams? Give the stream class hierarchy. 10

b) What is a virtual function? Illustrate with an example the usage of virtual functions

10

8. Write short notes on:

a) File input/output operations b) Late

binding

c) Pure virtual functions

d) Linkage directives