Вы находитесь на странице: 1из 3

UNIT III STREAMS STREAMS 1. What is stream?

A stream is a series of bytes, which act either as a source from which input data can be extracted or as a destination to which the output can be sent. The source stream provides data to the program called the input stream and the destination stream that receives the data from the program is called the output stream. C++ STREAMS 2. What are C++ streams? The C++ language offers a mechanism which permits the creation of an extensible and consistent input-output system in the form of streams library. It is a collection of classes and ob ects which can be used to build a powerful system, or modified and extended to handle the user-defined data types. 3. List C++ predefined standard streams and define. The four standard streams are! "i# cin $ %tandard input"usually &eyboard# corresponding to stdin in c "ii# cout $ %tandard output"usually screen# corrresponding to stdout in c. "iii# cerr $ %tandard error output"usuallly screen# corrresponding to stderr in c. "iv# clog $ A fully buffered version of cerr " 'o C e(uivalent# These are automatically opened before the function main"# is executed and they are closed after main"# has completed. . C!mpare I"# $sin% C and C++ S.N# ). ,. -. 4. I"# USIN& C The header file used for I*+ operation is stdio.h The function declared in stdio.h are printf , scanf etc., The statement to read data is scanf"./d0,1x#2 The statement to display the value of variable x is printf"./d0,x#2 I"# USIN& C++ The header file used for I*+ operation is iostream.h The function declared in stdio.h are cout, cin etc., The statement to read data is cin33x2 The statement to display the value of variable x is cout55i2

'( What is e)*epti!n hand+in%? 6xceptions refer to unusual conditions in a program. The unusual conditions could be faults, causing an error which in turn causes the program to fail. The error handling mechanisms of C++ is generally referred to as exception handling. ,( What are the spe*ia+ f$n*ti!ns t! hand+e $n*a$%ht e)*epti!ns? "i# terminate"# "ii# set7terminate"# "iii# unexpected"# "iv# set7unexpected"# -( What are f$n*ti!n temp+ate? A template in c++ allows the construction of a family of template functions and classes to perform the same operation on different data types. The templates declared fro functions are called function templates. .( What are *+ass temp+ates? A template in c++ allows the construction of a family of template functions and classes to perform the same operation on different data types. The templates declared for classes are called class templates. /( What is meant 01 inheritan*e? Inheritance is the process by which ob ects of one class ac(uire the properties of another class. It supports the concept of hierarchical classification. It provides the idea of reusability. 8e can add additional features to an existing class without modifying it by deriving a new class from it. 12( What is meant 01 sin%+e inheritan*e? If a single class is derived from a single base class is called single inheritance. 6g! 9ase class :erived class ;ere class A is the base class from which the class : is derived. Class : is the public derivation of class 9 hence it inherits all the public members of 9. 9ut : cannot access private members of 9. 11( What is m$+tip+e inheritan*e? If a class is derived from more than one base class, it is called multiple inheritance. 6g! 9ase classes :erived class ;ere class C is derived from two base classes A 1 9. 12( What is hierar*hi*a+ inheritan*e? If a number of classes are derived from a single base class then it is called hierarchical inheritance.

6g ! ;ierarchical classification of students in <niversity 13( What is m$+ti+e3e+ inheritan*e? If a class is derived from a class, which in turn is derived from another class, is called multilevel inheritance. This process can be extended to any number of levels. 6g! 9ase class =rand father Intermediate 9ase class >ather :erived class Child 1 ( What is h10rid inheritan*e? It is the combination of one or more types of inheritance. ?ultilevel inheritance ?ultiple inheritance The class result will have both the multilevel and multiple inheritances. 1'( What is meant 01 A0stra*t 0ase *+ass? A class that serves only as a base class from which derived classes are derived. 'o ob ects of an abstract base class are created. A base class that contains pure virtual function is an abstract base class. 1,( Write sh!rt n!tes !n 3irt$a+ 0ase *+ass. A base class that is (ualified as virtual in the inheritance definition. In case of multiple inheritance, if the base class is not virtual the derived class will inherit more than one copy of members of the base class. >or a virtual base class only one copy of members will be inherited regardless of number of inheritance paths between base class and derived class. 6g! @rocessing of studentsA results. Assume that class sports derive the roll number from class student. Class test is derived from class %tudent. Class result is derived from class Test and sports. As a virtual base class As a virtual base class 1-(4efine 5!+1m!rphism? @olymorphism is the feature that allows one interface to be used for a general class of actions."ie# .one interface multiple methods0. This means that it is possible to design a generic interface to a group of related activites.This helps reduce complexity by all. 1, mar6s 1(E)p+ain the *+ass temp+ates 7ith an e)amp+e 2(E)pa+in the f$n*ti!n temp+ates 7ith an e)amp+e 3(E)p+ain the e)*epti!n hand+in% 7ith an e)amp+e. (E)p+ain STL. '(E)p+ain the t1pes !f inheritan*e 7ith an e)amp+e.

Вам также может понравиться