Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

OBJECT ORIENTED PROGRAMMING DESIGN

Rating
-
Sold
-
Pages
66
Uploaded on
24-02-2023
Written in
2022/2023

Files: File Stream classes – Checking for errors – file opening modes – file pointers and manipulators – manipulators with arguments – read and write operations – Binary and ASCII files – Random access operation – Error handling functions – command line arguments – stdstreams. Generic Programming with Templates: Generic Functions- Need of Template – Normal function template – class template with more parameters – Function template with more parameters, overloading of function templates, class template with overloaded operators – class templates and inheritance. Exception Handling: Fundamentals of Exception Handling – Catching Class Types – Using Multiple catch statements – Catching All Exception – Rethrowing Exception – Specifying Exception – Exceptions in constructors and destructors – controlling uncaught Exceptions – Exception and operator overloading – Exception and inheritance – Class Template and Exception handling.

Show more Read less
Institution
Course

Content preview

CS T33 OBJECT ORIENTED PROGRAMMING AND DESIGN Y2/S3



Subject Name: OBJECT ORIENTED PROGRAMMING DESIGN

Subject Code: CS T33:

2 MARKS AND 11 MARKS

UNIT IV

Files: File Stream classes – Checking for errors – file opening modes – file pointers and
manipulators – manipulators with arguments – read and write operations – Binary and ASCII
files – Random access operation – Error handling functions – command line arguments –
stdstreams.

Generic Programming with Templates: Generic Functions- Need of Template – Normal
function template – class template with more parameters – Function template with more
parameters, overloading of function templates, class template with overloaded operators – class
templates and inheritance.

Exception Handling: Fundamentals of Exception Handling – Catching Class Types – Using
Multiple catch statements – Catching All Exception – Rethrowing Exception – Specifying
Exception – Exceptions in constructors and destructors – controlling uncaught Exceptions –
Exception and operator overloading – Exception and inheritance – Class Template and Exception
handling.




PART A – 2 MARK QUESTIONS

1. What are the various traditional error handling methods?
The various traditional error handling methods are,
i. Returning error number.
ii. Global flag manipulation.
iii. Abnormal termination.

,CS T33 OBJECT ORIENTED PROGRAMMING AND DESIGN Y2/S3

2. What is the importance of exceptional handling?
The importance of exceptional handling is,

i. Divide the error handling.

Ii.To provide unconditional termination and programmer preferred termination

iii. For separating error reporting and error handling.

iv. To solve the object destroy problem.

3. What are the three keywords used for exception handling mechanism?
The three keywords used for exception handling mechanism are,

i. try : for indicating program area where the exception can be thrown.

ii. throw: for throwing an exception.

iii. catch: for taking an action for specific exception.

4. What is the use of unexpected function?
The unexpected function is called when a function throws an exception not listed in its
exception specification. Internally, it calls the terminate function to terminate the
program execution. The function set unexpected () is used to call our own unexpected
function in place of the built-in unexpected function.

5. What are the challenges in the exception handling mechanism?
The challenges in the exception handling mechanism are,

i. Finding proper catch block.

ii. Finding proper catch block for polymorphic object.

iii. Backtracking till the beginning of the try block.



6. Why Templates are used in C++?
The Templates are used to develop reusable software component such as functions,
classes, etc. Templates allow the construction of a family of templates functions and
classes to perform the same operations on different data types.


7. What are rules for invalid function template declaration?
The rules for invalid function template declaration are,
i. No-argument template function.
ii. Template–type argument unused.
iii. Usage of partial number of template arguments.

8. Write the syntax for function Template.

,CS T33 OBJECT ORIENTED PROGRAMMING AND DESIGN Y2/S3


The syntax for function Template is,
Template <class T, .......... >
Return Type Fun_Name (arguments)
{
………. // body of the template
}

9. What are the error handling function in C++?
The error handling function in C++ is,
i. eof()
ii. fail()
iii. bad()
iv. good()


10. What are the rules for virtual function?

The rules for virtual function are,
i. They cannot be static members.
ii. They are access by using object pointers.
iii. A virtual function can be a friend of another class.

11. What are Streams?

Stream is a mechanism, which supplies the input data to a program and presents the
processed data in the desired form.

12. What are the file stream classes in C++?
The file stream classes in C++ are,
i. filebuf
ii. fstreambase
iii. ifstream
iv. ofstream
v. fstream

13. List out the ways of Class Template inheritance.

The ways of Class Template inheritance are,
i. Derive a class template from a base class, which is a template class
ii. Derive a class template from the base class, which is a template class, add more
template members in the derived class
iii. Derive a class template from a base class which is not a template class, and
add template members to that class
iv. Derive a class template from a base class which is a template class and restrict
the template feature.

, CS T33 OBJECT ORIENTED PROGRAMMING AND DESIGN Y2/S3


14. What are the functions of ios classes?

The functions of ios classes are,
Function Task Performed
width() Specifies the required number of
fields to be used while displaying
the output value.

precision() Specifies the number of digits to
be displayed after the decimal
point

fill() Specifies a character to be used to
fill the unused area of a field.

setf() Sets format flag that control the
form of output display

unset() Clears the specified flag




15. What are the modes used file stream class?
The modes used file stream class is,

i. in – open for reading
ii. out – open for writing
iii. app – all write occur at end of file
iv. trunc – truncate the file if already exits
v. nocreate – open fails if file does not exits
vi. noreplace – open fails if file already exits
vii. binary – open as a binary file


16. What is get () and put () functions?
get() is a member function of a stream class fstream and is used to read a single
character from a file. put() is a member function of a stream class fstream and is used to write
a single character to the file.

17. What are two types of file pointers used in C++?
The two types of file pointers used in C++ are,
i. get pointer – specifies a location from where the current reading operation is initiated
ii. put pointer - specifies a location from where the current writing operation is initiated

Written for

Institution
Course

Document information

Uploaded on
February 24, 2023
Number of pages
66
Written in
2022/2023
Type
Class notes
Professor(s)
Swathilakshmi
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
vigneshsivakumar

Get to know the seller

Seller avatar
vigneshsivakumar Sri Manakula Vinayagar Engineering College
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions