Professional Documents
Culture Documents
2.inline qualifier substitues the function code in place of calls thus makings
functions execute faster but creates multiple copies of functions thus increasing
program memory.
3.Call by value and reference
4.Unary scope resolution operator(::) used to refer to global variable if v havname
for local adn global variables with same name)
5.Generic programming using function templates.
6.Pointer variable stores the address of variable.
7.Reference variable is just a another name to the variable.
eg.int x=3
int *xptr=&x // xptr contains the address of x
int &xref=x // xref is another name for x
*xptr=7
xref=7 //both change value of x to 7
8.Always inialize constant member of classes using Member Initializer syntax of
Constructors.Else error will be thrown.
9.Friend function are non member functions of class that can modify the non-public
data.
Used when overloading operators for operation on user defined objects.
10.Dynamic memory allocation using new operator(analogous to malloc in C)
11.Destructors for dynamically created objects are not called automatically(But
user has to use the keyword delete to call the destructor)
12.Declaring a class member as static creates only a single copy for all objects of
that class.
13.An operator can be overloaded in two ways:
a) As a member function of class:In this case the left operand should be an
object of that class
b)As a non-member global function taking the objects as input parameters.(As a
friend function)
14.Inheritance:
a).It is a form of software reuse in which you create a class that absorbs the
capabilities of a derived class.
b).Protected members-->can be accessed in derived class
.Private member cannot be directly accessed in derived class.But can be
accessed by base class member functions.
c)Constructor of Base Class is called first and Destructor of derived class is
called first.
d)Use private members only in inheritance rather than protected member(For
better security).
15.a)Polymorphism is ability of program to take multiple forms
b)A Pointer handle decides whether to call base class version or derived class
version.
Eg, Baseclass ptr--->BAse class Object calls base class version
Baseclass ptr--->Derived class objects calls base class version for that
derived class object.
Thus a Baseclass pointer cannot be used to call Derived Class specifc
functions normally.
Exceptions
i) Using virtual functions and overridinden functions in derived class.
ii) Using Downcasting i.e dynamic cast a base class pointer to derived class
pointer.
c)Abstract class is a class whiich will be inherited but its own Object has no
meaning.
can be declared abstract by declaring one of its function as pure virtual.
16.Using Stream input output
cin--->istream &(Object of class basic_istream)
cout--->ostream &(Object of class basic_ostream)
cerr and clog--->ostream &(Unbuffered and Buffered error stream)
<iostream> Header inherits from basic_istream and basic_ostream
<iomanip>Header used to manipulate streams eg setw and setprecision etc
functions