Posts

Showing posts with the label C plus programming

Concept of Stream and It's bytestream class in c++

Image
Concept of streams:- Concept of stream  A stream is general name given to flow of data A stream is a sequence of byte. The source stream that provides data to programs is called input stream. The destination stream receive output from the program is called output stream. In header <iostream>, a set of class is defined that supports I/O operations. The classes used for input/output to the devices are declared in the IOSTREAM file. The classes used for disk file are declared in the FSTREAM file. Input/output stream :- Input and output stream in c++ Stream class for console I/O operations :- stream class in c++ ios class contains basic facilities that are used by all other input and output classes (Necessary for formatted input/output). Also contains pointer to a buffer object(streambuf). streambuf provided an interface to physical devices through buffer. iostream class inherits proper...

Question based on c++ that every programmer must know..

Question 1) What is use of default constructor ? Answer :-  Default constructor have a initialization code to connect vvptr to VTABLE . This is the one of the reason that the constructor can not be declared as virtual. Question 2) What is the size of an object? Answer:-   If we set virtual function in our class then the size of obj is size if data member + 2 bytes for vvptr (By default). Question 3)  why constructor can not be declared as virtual ? Answer:- As I told you in answer no. 3 that constructor have a initialization code to connect vvptr to VTABLE . If we create constructor in our class as virtual then c++ generates syntax error because according to the rule of c++ only constructor are able to have a code of initialization and no other function keep this code. That's a reason that constructor can not be declared as virtual. Question 4) why late binding is slow? Answer :- Because when our program doing late bi...