2. TOPIC COVERED
What is object oriented programming?
Why Do We Need Object-Oriented Programming?
Features of Object oriented programming-
Encapsulation, Data hiding, Inheritance, Polymorphism
Basic structure of C++ program
Variables
Keywords
Comments
3. BASIC STRUCTURE:
C Program structure
Header File
Main function
Works similar like printf function
namespace
return 0 must their in last 2 code
•A namespace is a declarative region
that provides a scope to the
identifiers (the names of types,
functions, variables, etc) inside it.
4. COMMENTS IN C++
C++ supports single-line and multi-line comments. All
characters available inside any comment are ignored by
C++ compiler.
C++ comments start with /* and end with */.
A comment can also start with //, extending to the end of
the line.
5. EXAMPLES:
For example :- -> Multiline comment
/* This is a comment */
For example −
Header File
When the above
code is
compiled, it will
ignore // prints
Hello World
6. VARIABLE IN C++
A variable provides us with named storage that our programs can
manipulate.
The name of a variable can be composed of letters, digits, and the
underscore character. It must begin with either a letter or an underscore.
Upper and lowercase letters are distinct because C++ is case-sensitive.
7. BASIC TYPES OF VARIABLE IN C++ :
Sr.No Type & Description
1. bool
Stores either value true or false.
2. char
Typically a single octet (one byte). This is an integer type.
3. Int
4. float
A single-precision floating point value.
5. double
A double-precision floating point value.
C++ also allows to define various other types of variables, which we will cover in
subsequent chapters like Enumeration, Pointer, Array, Reference, Data
structures, and Classes.
8. CONTD….
A variable definition tells the compiler where and how much storage to
create for the variable. A variable definition specifies a data type, and
contains a list of one or more variables of that type as follows:
type variable_list;
Here, type must be a valid C++ data type including char, w_char, int, float,
double, bool or any user-defined object, etc., and variable_list may consist
of one or more identifier names separated by commas. Some valid
declarations are shown here −
int i, j, k;
char c, ch;
float f, salary;
double d;
The line int i, j, k; both declares and defines the variables i, j and k; which
instructs the compiler to create variables named i, j and k of type int.
9. KEYWORDS IN C++
•The following list shows the reserved words in C++. These reserved words
may not be used as constant or variable or any other identifier names.