Question paper review:
hi I believe all of you wrote good for cpp exam. Here I analyze which appears to be confusion for you
hi I believe all of you wrote good for cpp exam. Here I analyze which appears to be confusion for you
- What is the Principle of OOP?
- Define Constructor. Write is syntax.
- Compare classes in C++ with structures in C.
- Define Pass by reference method
- List the uses of references.
It is nothing but Properties of OOP's. If u write at least 4 properties also you get full marks
(actually there are two kinds of Function calls (1)Pass by Value (2) Pass by Reference. Do u remember I explained swap the values using pass by reference while explaining the Reference variable.)
- Ans: /*see the notes for advantages of reference variable. This question is most frequently asked question in Interviews >
- 5) No complexity
- State the relationship between base class and derived class.
- State any three Benefits of Inheritance.
- State the need for Virtual Functions in C++.
- How will you overload Unary and binary operator using Friend functions?
- (a)Explain the structure of C++ program with an example program.
- Write a C++ program function overloading.
- Explain the creating and accessing of array of objects with an example program.
- Write a C++ program to illustrate multiple inheritance.
- Write a C+ program to illustrate virtual base class in multipath inheritance.
- Explain the various file stream classes needed for File Manipulators.
- Explain a class template for stack data structures.
Ans:
Ans:/* if you write the definition of virtual function it is enough */
(i) main reason for having a virtual function is to implement a different functionality in the derived class.
(ii) to add (means we can redefine in derived class) more facility to that function
(iii)virtual functions are needed to develop late binding concepts.
9. Define custom / user defined manipulators.
Ans: Actually this question is unexpected question.
There are two kinds of manipulators
(1) standard I/O manipulators
(2)User defined(custom) manipulators
if you write the standard I/O manipulators also they may give you the marks
An important feature of c++ streams is that they also work well with user-defined manipulators as they do with predefined(build-in) manipulators. Hence, the users can design their own(customized) manipulators to control the appearance of the output depending upon their taste and need. The syntax for crating a custom manipulators is shown as follows. In the syntax, manipulator is the name of the user defined manipulator. Output is the manipulator caller and stream cascading object and arguments if any is used for arguments for parameterized manipulator.
Syntax:
Ostream& manipulator(ostream &output, argements)
{
-------
-------
-------
return statement;
}
/*to see the answer then go to 4th chapter C++ I/O
10. What is Generic programming?
Ans: Generic Programming is nothing but Templates. I hope you wrote this question
PART- B 5*10=50
Ans: we know that there are two types of operator overloading:
(i) unary operator overloading
(ii)binary operator overloading
Ans:
(b) Explain the steps in developing a C++ program.
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
(i) Ofstream: stream class to write on files
(ii)Ifstream: stream class to read from files
(iii)Fstream: stream class to both read and write from/to files.
these classes are derived directly or indirectly from the classes istream, and ostream. We have already used objects whose types were these classes: cin is an object of class istream and cout is an object of class ostream. Therefore, we have already been using classes that are related to out file streams. Ans in fact, we can use our file streams the same way we are already used to usecin and cout, with the only difference that we have to associate these streams with physical files:
(i) ifstream: this is the class for input operation on files similarly to statndard input. It includes the methods(functions) open(), close(), read(), get() getline(), and the overloaded extraction operator.
(ii) ofstream: this is the class for output operation of files. Similarly, to standard output methods included are open(), close(), put(), write() and the overloaded insertion oerator.,
(iii) fstream: this class derived from both ifstream and ofstream
all the classes are declared in the fstream.h header file. The file also includes iostream.h files
Ans: