3. C++ is an extension to C Programming
language. It was developed at AT&T Bell
Laboratories in the early 1980s by Bjarne
Stroustrup. It is a deviation from traditional
procedural languages in the sense that it
follows object oriented programming (OOP)
approach which is quite suitable for managing
large and complex programs.
5. The capability of one class to inherit properties
from another class as a child inherits some
properties from his/her parents.
The most important advantage of inheritance is
code reusability. Once a base class is written and
debugged, it can be used in various situations
without having to redefine it or rewrite it.
Reusing existing code saves time, money and
efforts of writing the code again. Without
redefining the old class, you can add new
properties to desired class and redefine an
inherited class member function.
7. Encapsulation is the most basic concept of OOP. It is
the way of combining both data and the functions that
operate on that data under a single unit. The only way
to access the data is provided by the functions (that are
combined along with the data). These functions are
considered as member functions in C++. It is not
possible to access the data directly. If you want to
reach the data item in an object, you call a member
function in the object. It will read the data item and
return the value to you. The data is hidden, so it is
considered as safe and far away from accidental
alternation. Data and its functions are said to be
encapsulated into a single entity.
17. Registered and reserved words of c++ are
known as a key word.
Not use to create variables.
18. List of Keywords
asm double new switch
auto else operator template
break enum private this
case extern protected try
catch float public typedef
char for register union
class friend return unsigned
const goto short virtual
continue if signed void
default inline sizeof volatile
delete int static while
do long struct
19. Brackets [ ] opening and closing brackets indicate
single and multidimensional array
subscript.
Parentheses ( ) opening and closing brackets indicate
functions calls, function parameters for
grouping expressions etc.
Braces { } opening and closing braces indicate the
start and end of a compound statement.
Comma , it is used as a separator in a function
argument list.
Semicolon ; it is used as a statement terminator.
Colon : it indicates a labelled statement or
conditional operator symbol.
Asterisk * it is used in pointer declaration or as
multiplication operator.
Equal sign = it is used as an assignment operator.
Pound sign # it is used as pre-processor directive.
46. Define in main four type.
No parameter no return value
No parameter with return value
With parameter no return
With parameter with return
54. User define data type
Key word Enum use to store only user define
data
enum day = {“Sunday” , ”Monday” , ”Tuesday”}
Index start from 0
Ex index of Sunday is 0.
55. Collection of different data type
User define data type
Access by . (Dot)
Define with struct keyword
56. struct structure name
{
Variable data type variable name
Variable data type variable name
Variable data type variable name
Up to n variables. . .
};
61. Class :
Collection of methods and variables.
Collection of private and public data.
Object :
Instants that Use to access functionality of class.
65. Create memory space on RAM.
Calling when creating object of any class
All class contains 1 default constructor.
Constructor name and class name both are
same.
Default constructor not take any parameters.
66. A constructor is a special member function that
initializes the objects of its class.
It is special because its name is the same as the class
name. It is invoked automatically whenever an object is
created. It is called constructor because it constructs
the values of data members of the class. It does not
have any return type, not even void.
67. class abc
{
◦ public:
◦ abc()
◦ {
Executable part
◦ }
};
68. Use to delete object of any class
Call by ~ sign.
Destructor never return any kind of values.
71. Re usability of any class
Extends on class in another class
Code re usability
Access methods and variables of super class
Inherit functionality of super class.
Use of pre define class
72. Mainly 5 type of inheritance available in c++
Single level inheritance
Multi level inheritance
Multiple inheritance
Hierarchical inheritance
Hybrid inheritance
73. Base class Derived class
Access public private protected
specifier
public public private protected
private Not Not Not
inherited inherited inherited
protected protected protected protected
84. Class name (parent)
{
}
Class name(child):access specification class
name( parent class )
{
}
Class name (sub child) : access specification
class name (parent class)
85. Class demo
{
}
Class demo1: public demo
{
}
Class demo2 : public demo1
{
}
93. Class class name
{
}
Class class name : access specification class name
{
}
Class class name : access specification class name
{
}
Class class name : access specification class name,
access specification class name
{
}
94. Class demo
{}
Class demo1 : public demo
{}
Class demo2 : public demo
{}
Class final : public demo1, public demo2
{}
95. A file is a collection of logically related
records. A program usually requires two
types of data communication.
96. Data Type Description
ofstream This data type represents the output file
stream and is used to create files and to
write information to files.
ifstream This data type represents the input file
stream and is used to read information
from files.
fstream This data type represents the file stream
generally, and has the capabilities of both
ofstream and ifstream which means it can
create files, write information to files, and
read information from files.
97. (i) Writing data on the datafile:
◦ The data flows from keyboard to memory and from
memory to storage device.
◦ Keyboard —> memory —> hard disk/floppydisk
(ii) Reading data from datafile:
◦ The data flows from storage device to memory and
from memory to output device, particularly monitor.
datafile —> memory — > output device (screen)
98. Mode Flag Description
ios::app Append mode. All output to that
file to be appended to the end.
ios::ate Open a file for output and move
the read/write control to the end
of the file.
ios::in Open a file for reading.
ios::out Open a file for writing.
ios::trunc If the file already exists, its
contents will be truncated before
opening the file.
101. While doing C++ programming,
you write information to a file from your
program using the stream insertion operator
(<<) just as you use that operator to output
information to the screen. The only difference is
that you use an ofstream or fstream object
instead of the cout object
102. You read information from a file into your
program using the stream extraction operator
(<<) just as you use that operator to input
information from the keyboard. The only
difference is that you use an ifstream or fstream
object instead of the cin object.
103. File has two associated pointers called input
pointer (or get pointer) and output pointer (or
put pointer). Each time an input or output
operation takes place, the pointer moves
automatically. There are two pointers.
seekg ( ) It moves get pointer to a
specified location.
seekp ( ) It moves the put pointer to a
specified location
104. Ios:: beg ios:: cur ios::end
ios :: beg means start of the file
ios :: cur means current position of the
pointer
ios :: end means end of the file
file
105. A pointer is a variable that represents the
location (rather than the value ) of a data
item such as a variable or an array element
106. Pointer variables declare with * sign.
And pointer variables access with & sign.
107. Int a = 10;
Int b = &a;
◦ In above example variable “a” is integer type
variable and variable “b” is also integer variable.
◦ Variable b store the reference of variable “a”
and when we use the variable “b” it return the value
of variable “a”.
108. Operator overloading is use to overload any
predefined operators.
Create class and with operator method and
write new code for any operator.
109. class class_name
{
public :
void operator sign of operator ()
{
new logic for operator
};
};
Main method
{
object and apply operator
}
111. Class name is demo.
Publicly overload ++ operator with simple
message.
d is object of demo class.
whenever you apply ++ operator then
compiler not increment any value in object,
But print simple message on screen.