Professional Documents
Culture Documents
C++ Programming Language-: Unit-1 1. Introduction To Oops and Basics of C++ 1.1 Object Oriented Programming
C++ Programming Language-: Unit-1 1. Introduction To Oops and Basics of C++ 1.1 Object Oriented Programming
6. Dynamic Binding:
Binding refers to the linking of a procedure call to the
code to be executed In response to the call. Dynamic
binding (also known as late binding) means that the code
associated with a given procedure call is not known until
the time of the call at run time.
It is associated with polymorphism and inheritance. A
function call associated with a polymorphism reference
depends on the dynamic type of that reference.
7. Message Passing:
An object oriented program consist of a set of
objects that communicate with each other. The process
of programming in an object oriented language,
therefore, involves the following basic steps:
1. Creating classes that define objects and their
behavior.
2. Creating objects from class definitions, and
3. Establishing communication among objects.
Objects communicate with one another by
sending and receiving information much the same
way as people pass messages to one another. The
concept of message passing makes it easier to talk
about building system that directly model or
simulate their real-world counterparts.
1.Numeric Constant:
The numeric constant are the number which is
again classified into two parts:
• Integer constant:
• Real or float constant:
• Integer constant:
A number does not include decimal points is called
integer constant. ex. Any natural numbers is an
example of this constant.
Ex. 500, -200 etc.
The integer constant defines some rule:
1. It does not include decimal point
2. It is a single digit
3. Default sign is positive
4. The range of this constant is -32768 to 32767
• Real or float constant:
A number include a decimal point is reffered as real or
float constant.
eg. 4.5, 6.45, -19.54 etc.
it defines the rules
Rules:-
1. It must include decimal point
2. It must only one decimal point is included
3. it may be either positive or negative
4. The default sign is positive
5. It is available in single pricigion and double pricigion.
6. The number in the range of -3.4e38 to 3.4e38.
7. The number is too large and too small, these numbers
are converted into exponent which is separated by a
letter e i.e. 3.4e38 where 3.4 is mantisa and 38 is
exponent.
2.Non numeric constant:
It is a character and not a number it is classified
into two types.
a. character constant:
b. string constant:
a. character constant:
It is a single character is must be enclosed is single
correct is referred as character constant. eg. ‘a’ ‘1’
etc.
b. string constant:
The group of character is called string. The string
constant consist of group of character it must be
enclosed in double coatation mark(“”) eg.
“mumu”, “welcome” etc.
• Data types:
Member function
class definition
Server
Main function
program
Client
The class definition including the member functions constitute
the server that provides service to the main program known as
client. The client uses the server through the public interface of
the class.
1.8 Control Structure:
In C++, a large number of functions are used that pass
messages, and process the data contained in objects. A
function is set up to perform a task. When the task is
complex, many different algorithms can be designed to
achieve the same goal. Some are simple to comprehend,
while other are not. Experience has also shown that the
number of bugs that occur is related to the format of the
program. All the simple types of program will be executed
from top to bottom but user wants to some part of the
program to be executed again and again then we can
usages control statement or control structure.
In C++ programming language there are three
conditional structure can be used i.e. Conditional
statement, looping statement and jumping statement
1. Conditional statement:
• if statement: syntax:
if(condition)
{
Statement block;
}
“if” is a conditional statement it execute given statement block,
if the condition is true. Condition is always written in
parenthesis after if keyword in same line. To check condition we
have to use relational or logical operator. If we have to exectute
more than one statement when condition is true, then we have to
write these statements within closing and opening curly
brackets{}
Program:
#include<iostream.h>
#include<conio.h>
void main( )
{
int marks;
clrscr( );
cout<<”enter your marks”;
cin>>marks;
if(marks>35)
{
cout<<”you are pass”;
}
cout<<”please check you marks”;
}
• if------else statement: syntax:
if (condition)
{
statement _block 1;
}
else
{
statement_block2;
}
“if---else” statement consist of two parts as ‘if’ block and ‘else’
block condition is always written in parenthesis after ‘if’
keyword in same line. To check the condition we have to use
relational or logical operators.
Program:
#include<iostream.h>
#include<conio.h>
Void main( )
{
int marks;
clrscr( );
cout<<”enter your marks”;
cin>>marks;
if(marks>=35)
{
cout<<”you are pass”;
}
Else
{
cout<<”you are fail”;
}
}
• Multiple if statement: syntax:
if (condition)
{
statement _block 1;
}
else
if (condition)
{
Statement _block2;
}
else
-----
-----
If (condition n)
{
statement _block n;
}
else
{
statements;
}
When more than one ‘if’ are placed in a series or sequence ,then
such ‘if’ structure is called as multiple structure. In this structure
first ‘if’ condition is checked if it is true then statement block is
executed. If condition is false then second ‘if’ condition is
checked. If it is true then, statement block for that ‘if’ is
executed and rest of ‘if’ conditions are skipped.
Program:
#include<iostream.h>
#include<conio.h>
Void main( )
{
Int num1, num2, ch;
Clrscr( );
Cout <<”enter values”;
Cin>>num1>>num2;
Cout<<”\add\n2sub\n3 mul \n4 div \n type choice (1-4):”;
Cin>>ch;
If (ch==1)
{
Cout<<”n\ addition is num1+num2”;
}
Else
If(ch