SlideShare uma empresa Scribd logo
1 de 41
Classes & Objects
Chap 5
3/11/2016 1By:-Gourav Kottawar
Contents
5.1 A Sample C++ Program with class
5.2 Access specifies
5.3 Defining Member Functions
5.4 Making an Outside Function Inline
5.5 Nesting of Member Functions
5.6 Private Member Functions
5.7 Arrays within a Class
5.8 Memory Allocation for Objects
5.9 Static Data Members, Static Member
5.10 Functions, Arrays of Objects
5.11 Object as Function Arguments
5.12 Friend Functions, Returning Objects,
5.13 Const member functions
5.14 Pointer to Members, Local Classes
5.15 Object composition & delegation
3/11/2016 2By:-Gourav Kottawar
Declaring Class
 Syntax –
class class_name
{
private :
variable declaration;
function declaration;
public:
variable declaration;
function declaration;
}
3/11/2016 3By:-Gourav Kottawar
Data hiding in classes
3/11/2016 4By:-Gourav Kottawar
Simple class program
Creating objects
Accessing class members
 Access specifies
private
public
protector
default - private
 5.3 Defining Member Functions
3/11/2016 5By:-Gourav Kottawar
5.4 Making an Outside Function Inline
class item
{
......
......
public:
void getdata(int a,float b);
};
inline void item :: getdata(int a,float b)
{
number=a;
cost=b;
}
3/11/2016 6By:-Gourav Kottawar
5.5 Nesting of Member Functions
#include<iostream.h>
#include<conio.h>
class data
{
int rollno,maths,science;
int avg();
public: void getdata();
void putdata();
};
main()
{
clrscr();
data stud[5];
for(int i=0;i<5;i++)
stud[i].getdata();
}
void data::getdata()
{
cout<<"Please enter rollno:";
cin>>rollno;
cout<<"Please enter maths marks:";
cin>>maths;
cout<<"Please enter science marks:";
cin>>science;
putdata();
}
int data::avg()
{
int a; a=(maths+science)/2;
return a;
}
void data::putdata()
{
cout<<"Average is :"<<avg()<<endl;
}
3/11/2016 7By:-Gourav Kottawar
5.7 Arrays within a Class
const int size=10;
class array
{
int a[size];
public:
void setval(void);
void display(void);
};
3/11/2016 8By:-Gourav Kottawar
Ex-
#include<iostream>
#include<string>
using namespace std;
const int val=50;
class ITEM
{
private:
int item_code[val];
int item_price[val];
int count;
public:
void initiliaze();
void get_item();
void display_item();
void display_sum();
void remove();
};
void ITEM::initiliaze()
{
count=0;
}
void ITEM::get_item()
{
cout<<"Enter the Item code == "<<endl;
cin>>item_code[count];
cout<<"Enter the Item cost == "<<endl;
cin>>item_price[count];
count++;
}
void ITEM::display_sum()
{
int sum=0;
for(int i=0; i<count;i++)
{
sum=sum + item_price[i];
}
cout<<"The Total Value Of The Cost Is ==
"<<sum<<endl;
}
3/11/2016 9By:-Gourav Kottawar
void ITEM::display_item()
{
cout<<"nCode Pricen";
for(int k=0;k<count;k++)
{
cout<<"n"<<item_code[k];
cout<<" "<<item_price[k];
}
}
void ITEM::remove()
{
int del;
cout<<"Enter the code you want to remove == ";
cin>>del;
for(int search=0; search<count; search++)
{
if(del == item_code[search])
{
item_price[search]=0;
item_code[search]=0;
}
}
}
3/11/2016 10By:-Gourav Kottawar
int main()
{
ITEM order;
order.initiliaze();
int x;
do
{
cout<<"nnYou have the following opton";
cout<<"nEnter the Appropriate number";
cout<<"nnPress 1 for ADD AN ITEMS";
cout<<"nnPress 2 for DISPLAY TOTAL
VALUE";
cout<<"nnPress 3 for DELETE AN
ITEM";
cout<<"nnPress 4 for DISPLAY ALL
ITEMS";
cout<<"nnPress 5 for QUIT";
cout<<"nEnter The Desired Number ==
n";
cin>>x;
switch(x)
{
case 1:
{
order.get_item();
break;
}
case 2:
{
order.display_sum();
break;
}
case 3:
{
order.remove();
break;
}
case 4:
{
order.display_item();
break;
}
3/11/2016 11By:-Gourav Kottawar
case 5:
break;
default: cout<<"Incorrect option Please
Press the right number == ";
}
}while(x!=5);
getchar();
return 0;
}
3/11/2016 12By:-Gourav Kottawar
5.8 Memory Allocation for Objects
common for all objects
member function 1
member function 2 memory created when
function defined
Object 1 object 2 object 3
Member varible 1 member variable 2 member
variable 1
Member variable 2 member variable 2 member variable 2
memory created
when objects defined
3/11/2016 13By:-Gourav Kottawar
5.9 Static Data Members, Static Member
 A data member of a class can be
qualified as static.
 The properties of a static member
variable are similar to that of a C static
variable.
 It is initialized to zero when the first
object of its class is created. No other
initialization is permitted.
 Only one copy of that member is created
for the entire class and is shared by all
the objects of that class, no matter how
many objects are created.
 It is visible only within the class, but its
lifetime is the entire program.
3/11/2016 14By:-Gourav Kottawar
#include
using namespace std;
class item
{
static int count;
int number;
public:
void getdata(int a)
{
number = a;
count ++;
}
void getcount(void)
{
cout << "Count: ";
cout << count <<"n";
}
};
int item :: count;
int main()
{
item a,b,c;
a.getcount();
b.getcount();
c.getcount();
a.getdata(100);
b.getdata(200);
c.getdata(300);
cout << "After reading
data"<<"n";
a.getcount();
b.getcount();
c.getcount();
return 0;
}
3/11/2016 15By:-Gourav Kottawar
#include
using namespace std;
class item
{
static int count;
int number;
public:
void getdata(int a)
{
number = a;
count ++;
}
void getcount(void)
{
cout << "Count: ";
cout << count <<"n";
}
};
int item :: count;
int main()
{
item a,b,c;
a.getcount();
b.getcount();
c.getcount();
a.getdata(100);
b.getdata(200);
c.getdata(300);
cout << "After reading
data"<<"n";
a.getcount();
b.getcount();
c.getcount();
return 0;
}
The output of
the program
would be:
Count: 0
Count: 0
Count: 0
After reading
data
Count: 3
Count: 3
Count: 3
3/11/2016 16By:-Gourav Kottawar
Sharing of a static data
member
3/11/2016 17By:-Gourav Kottawar
Static member function
 A member function that is declared
static has following properties
1. A static function can have access to
only other static members (functions
or variables) declared in the same
class.
2. A static member function can be
called using the class name (instead
of its objects ) as follows :
class – name :: function – name;3/11/2016 18By:-Gourav Kottawar
3/11/2016 19
class Something
{
private:
static int s_nValue;
public:
static int GetValue() { return s_nValue; }
};
int Something::s_nValue = 1; // initializer
int main()
{
std::cout << Something::GetValue() <<
std::endl;
}
By:-Gourav Kottawar
3/11/2016 20
class IDGenerator
{
private:
static int s_nNextID;
public:
static int GetNextID() { return
s_nNextID++; }
};
// We'll start generating IDs at 1
int IDGenerator::s_nNextID = 1;
int main()
{
for (int i=0; i < 5; i++)
cout << "The next ID is: " <<
IDGenerator::GetNextID() << endl;
return 0;
}
The next ID is: 1
The next ID is: 2
The next ID is: 3
The next ID is: 4
The next ID is: 5
By:-Gourav Kottawar
3/11/2016 21
class IDGenerator
{
private:
static int s_nNextID;
public:
static int GetNextID() { return s_nNextID++; }
};
// We'll start generating IDs at 1
int IDGenerator::s_nNextID = 1;
int main()
{
for (int i=0; i < 5; i++)
cout << "The next ID is: " << IDGenerator::GetNextID() <<
endl;
return 0;
}
By:-Gourav Kottawar
Array of object
3/11/2016 22By:-Gourav Kottawar
5.11 Object as Function Arguments
 Two ways
1. A copy of the entire object is passed
to the function.
i.e. pass by value
2. Only the address of the object is
transferred to the function
i.e. pass by reference
3/11/2016 23By:-Gourav Kottawar
3/11/2016 24By:-Gourav Kottawar
3/11/2016 25
#include <iostream>
using namespace std;
class Complex
{
private: int real;
int imag;
public:
void Read()
{
cout<<"Enter real and imaginary number
respectively:"<<endl; cin>>real>>imag;
}
void Add(Complex comp1,Complex comp2)
{
real=comp1.real+comp2.real;
/* Here, real represents the real data of object c3 because this function is
called using code c3.add(c1,c2); */
imag=comp1.imag+comp2.imag;
/* Here, imag represents the imag data of object c3 because this function
is called using code c3.add(c1,c2); */
}
By:-Gourav Kottawar
3/11/2016 26
void Display()
{
cout<<"Sum="<<real<<"+"<<imag<<"i";
}
};
int main()
{
Complex c1,c2,c3;
c1.Read();
c2.Read();
c3.Add(c1,c2);
c3.Display();
return 0;
}
By:-Gourav Kottawar
Returning Object from Function
3/11/2016 27By:-Gourav Kottawar
3/11/2016 28
#include <iostream>
using namespace std;
class Complex
{
private: int real;
int imag;
public: void Read()
{
cout<<"Enter real and imaginary number respectively:"<<endl;
cin>>real>>imag;
}
Complex Add(Complex comp2)
{
Complex temp;
temp.real=real+comp2.real;
/* Here, real represents the real data of object c1 because this
function is called using code c1.Add(c2) */
temp.imag=imag+comp2.imag;
/* Here, imag represents the imag data of object c1 because this
function is called using code c1.Add(c2) */
return temp; 0;
} By:-Gourav Kottawar
3/11/2016 29
}
void Display()
{
cout<<"Sum="<<real<<"+"<<ima
g<<"i"; }
};
int main()
{
Complex c1,c2,c3;
c1.Read();
c2.Read();
c3=c1.Add(c2);
c3.Display();
return 0;
}
By:-Gourav Kottawar
5.12 Friend function
 Need
a data is declared as private inside a
class, then it is not accessible from
outside the class.
A function that is not a member or an
external class will not be able to access
the private data.
A programmer may have a situation
where he or she would need to access
private data from non-member functions
and external classes. For handling such
cases, the concept of Friend functions is
a useful tool.
3/11/2016 30By:-Gourav Kottawar
5.12 Friend function
What is a Friend Function?
 A friend function is used for accessing
the non-public members of a class.
 A class can allow non-
member functions and other classes to
access its own private data, by making
them friends.
 Thus, a friend function is an ordinary
function or a member of another class.
3/11/2016 31By:-Gourav Kottawar
5.12 Friend function
 General syntax
Class ABC
{
…..
…..
public :
…..
…..
Friend void func1(void);
};
3/11/2016 32By:-Gourav Kottawar
5.12 Friend function
Special Characteristics
 The keyword friend is placed only in the function declaration
of the friend function and not in the function definition.
 It is not in the scope of the class to which it has been declared
as friend.
 It is possible to declare a function as friend in any number of
classes.
 When a class is declared as a friend, the friend class has access
to the private data of the class that made this a friend.
 A friend function, even though it is not a member function,
would have the rights to access the private members of the
class.
 It is possible to declare the friend function as either private or
public without affecting meaning.
 The function can be invoked without the use of an object.
 It has object as argument.
3/11/2016 33By:-Gourav Kottawar
3/11/2016 34
#include <iostream>
using namespace std;
class exforsys
{
private:
int a,b;
public:
void test()
{
a=100;
b=200;
}
friend int compute(exforsys e1);
//Friend Function
Declaration with keyword friend and
with the object of class exforsys to
which it is friend passed to it
};
int compute(exforsys e1)
{
//Friend Function Definition
which has access to private data
return int(e1.a+e1.b)-5;
}
void main()
{
exforsys e;
e.test();
cout << "The result is:" <<
compute(e);
//Calling of Friend
Function with object as argument.
}
By:-Gourav Kottawar
Constant Member Functions
 Declaring a member function with
the const keyword specifies that the
function is a "read-only" function that
does not modify the object for which it is
called.
 A constantmember function cannot
modify any non-static data members or
call any member functions that aren't
constant.
 The const keyword is required in both the
declaration and the definition.
3/11/2016 35By:-Gourav Kottawar
Constant Member Functions –
EXclass Date
{
public:
Date( int mn, int dy, int yr );
int getMonth() const; // A
read-only function
void setMonth( int mn ); // A
write function; can't be const
private:
int month;
};
int Date::getMonth() const
{
return month; // Doesn't
modify anything
}
3/11/2016 36
void Date::setMonth( int mn )
{
month = mn; // Modifies data
member
}
int main()
{
Date MyDate( 7, 4, 1998 );
const Date BirthDate( 1, 18, 1953
); MyDate.setMonth( 4 ); // Okay
BirthDate.getMonth(); // Okay
BirthDate.setMonth( 4 ); // C2662
Error
}
By:-Gourav Kottawar
5.14 Pointers to members
 Pointers to members allow you to refer to nonstatic
members of class objects.
 You cannot use a pointer to member to point to a static
class member because the address of a static member is
not associated with any particular object.
 To point to a static class member, you must use a
normal pointer.
 You can use pointers to member functions in the same
manner as pointers to functions.
 You can compare pointers to member functions, assign
values to them, and use them to call member functions.
 Note - a member function does not have the same type
as a nonmember function that has the same number
and type of arguments and the same return type.
3/11/2016 37By:-Gourav Kottawar
5.14 Pointers to members - Ex
#include <iostream>
using namespace std;
class X
{
public:
int a;
void f(int b)
{
cout << "The value of b is
"<< b << endl;
}
};
3/11/2016 38
int main()
{
// declare pointer to data member
int X::*ptiptr = &X::a;
// declare a pointer to member
function
void (X::* ptfptr) (int) = &X::f;
// create an object of class type X
X xobject;
// initialize data member
xobject.*ptiptr = 10;
cout << "The value of a is " <<
xobject.*ptiptr << endl;
// call member function
(xobject.*ptfptr) (20);
}
By:-Gourav Kottawar
5.14 Local Classes
 A local class is declared within a function
definition.
 Declarations in a local class can only use type
names, enumerations, static variables from the
enclosing scope, as well as external variables and
functions.
 Member functions of a local class have to be
defined within their class definition, if they are
defined at all.
 As a result, member functions of a local class are
inline functions. Like all member functions, those
defined within the scope of a local class do not need
the keyword inline.
3/11/2016 39By:-Gourav Kottawar
3/11/2016 40
int x; // global variable
void f() // function definition
{
static int y; // static variable y can be used by local class
int x; // auto variable x cannot be used by local class
extern int g(); // extern function g can be used by local class
class local // local class
{
int g() { return x; } // error, local variable x
// cannot be used by g
int h() { return y; } // valid,static variable y
int k() { return ::x; } // valid, global x
int l() { return g(); } // valid, extern function g
};
}
int main()
{
local* z; // error: the class local is not
visible
// ...}
By:-Gourav Kottawar
3/11/2016 41
A local class cannot have static data members.
void f()
{
class local
{
int f(); // error, local class has noninline
// member function
int g() {return 0;} // valid, inline member
function
static int a; // error, static is not allowed for //
local class
int b; // valid, nonstatic variable
};
} // . . .
By:-Gourav Kottawar

Mais conteúdo relacionado

Mais procurados

Lean React - Patterns for High Performance [ploneconf2017]
Lean React - Patterns for High Performance [ploneconf2017]Lean React - Patterns for High Performance [ploneconf2017]
Lean React - Patterns for High Performance [ploneconf2017]Devon Bernard
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - PraticalsFahad Shaikh
 
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmKotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmFabio Collini
 
Best Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part IIBest Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part IIICS
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutinesFabio Collini
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)RichardWarburton
 
Kotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confKotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confFabio Collini
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0Tobias Meixner
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose worldFabio Collini
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)Darwin Durand
 
Droidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfDroidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfAnvith Bhat
 
Testing Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKTesting Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKFabio Collini
 
FormsKit: reactive forms driven by state. UA Mobile 2017.
FormsKit: reactive forms driven by state. UA Mobile 2017.FormsKit: reactive forms driven by state. UA Mobile 2017.
FormsKit: reactive forms driven by state. UA Mobile 2017.UA Mobile
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
 
The art of reverse engineering flash exploits
The art of reverse engineering flash exploitsThe art of reverse engineering flash exploits
The art of reverse engineering flash exploitsPriyanka Aash
 

Mais procurados (19)

Lean React - Patterns for High Performance [ploneconf2017]
Lean React - Patterns for High Performance [ploneconf2017]Lean React - Patterns for High Performance [ploneconf2017]
Lean React - Patterns for High Performance [ploneconf2017]
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - Praticals
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmKotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere Stockholm
 
Best Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part IIBest Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part II
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutines
 
The zen of async: Best practices for best performance
The zen of async: Best practices for best performanceThe zen of async: Best practices for best performance
The zen of async: Best practices for best performance
 
Why Sifu
Why SifuWhy Sifu
Why Sifu
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
 
Kotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confKotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community conf
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose world
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
 
Droidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdfDroidjam 2019 flutter isolates pdf
Droidjam 2019 flutter isolates pdf
 
Testing Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKTesting Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UK
 
FormsKit: reactive forms driven by state. UA Mobile 2017.
FormsKit: reactive forms driven by state. UA Mobile 2017.FormsKit: reactive forms driven by state. UA Mobile 2017.
FormsKit: reactive forms driven by state. UA Mobile 2017.
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...
 
The art of reverse engineering flash exploits
The art of reverse engineering flash exploitsThe art of reverse engineering flash exploits
The art of reverse engineering flash exploits
 

Destaque

Strengthening the environment for web entrepreneurs in europe 22 november 2011
Strengthening the environment for web entrepreneurs in europe 22 november 2011Strengthening the environment for web entrepreneurs in europe 22 november 2011
Strengthening the environment for web entrepreneurs in europe 22 november 2011IAMCP MENTORING
 
Lesson4humanimpactonbiosphere
Lesson4humanimpactonbiosphereLesson4humanimpactonbiosphere
Lesson4humanimpactonbiospheresarah marks
 
Holly Molly catalogo inv2015 precios x menor
Holly Molly catalogo inv2015   precios x menorHolly Molly catalogo inv2015   precios x menor
Holly Molly catalogo inv2015 precios x menorMariana Duche
 
The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...
The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...
The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...Brent Alexander Newton, JD, CPA, MAc
 
個資法 - 資料就是財富
個資法 - 資料就是財富個資法 - 資料就是財富
個資法 - 資料就是財富ChrisChenTw
 
International experience in REC mechanismmr
International experience in REC mechanismmrInternational experience in REC mechanismmr
International experience in REC mechanismmrAnuj Kaushik
 
σκληρός+δ..
σκληρός+δ..σκληρός+δ..
σκληρός+δ..giota89
 
Commscope-Andrew ATBT-S522
Commscope-Andrew ATBT-S522Commscope-Andrew ATBT-S522
Commscope-Andrew ATBT-S522savomir
 
แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559
แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559
แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559ประพันธ์ เวารัมย์
 
3Com 3C17224-RE
3Com 3C17224-RE3Com 3C17224-RE
3Com 3C17224-REsavomir
 

Destaque (18)

Strengthening the environment for web entrepreneurs in europe 22 november 2011
Strengthening the environment for web entrepreneurs in europe 22 november 2011Strengthening the environment for web entrepreneurs in europe 22 november 2011
Strengthening the environment for web entrepreneurs in europe 22 november 2011
 
学生演示文稿
学生演示文稿学生演示文稿
学生演示文稿
 
Interview
InterviewInterview
Interview
 
Hi 5 powerpoint
Hi 5 powerpointHi 5 powerpoint
Hi 5 powerpoint
 
Lesson4humanimpactonbiosphere
Lesson4humanimpactonbiosphereLesson4humanimpactonbiosphere
Lesson4humanimpactonbiosphere
 
Holly Molly catalogo inv2015 precios x menor
Holly Molly catalogo inv2015   precios x menorHolly Molly catalogo inv2015   precios x menor
Holly Molly catalogo inv2015 precios x menor
 
The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...
The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...
The Factors Affecting the Location of Foreign Direct Investment by U.S. Compa...
 
個資法 - 資料就是財富
個資法 - 資料就是財富個資法 - 資料就是財富
個資法 - 資料就是財富
 
Empirical Reasearch Project
Empirical Reasearch ProjectEmpirical Reasearch Project
Empirical Reasearch Project
 
International experience in REC mechanismmr
International experience in REC mechanismmrInternational experience in REC mechanismmr
International experience in REC mechanismmr
 
σκληρός+δ..
σκληρός+δ..σκληρός+δ..
σκληρός+δ..
 
A
AA
A
 
Sun Web Server Brief
Sun Web Server BriefSun Web Server Brief
Sun Web Server Brief
 
Commscope-Andrew ATBT-S522
Commscope-Andrew ATBT-S522Commscope-Andrew ATBT-S522
Commscope-Andrew ATBT-S522
 
แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559
แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559
แจ้งผลการประชุม ก.จ. ก.ท. และ ก.อบต. ครั้งที่ 10/2559 เมื่อวันที่ 28 ตุลาคม 2559
 
3Com 3C17224-RE
3Com 3C17224-RE3Com 3C17224-RE
3Com 3C17224-RE
 
1 news item
1 news item1 news item
1 news item
 
What is technology
What is technologyWhat is technology
What is technology
 

Semelhante a classes & objects in cpp overview

classes & objects in cpp
classes & objects in cppclasses & objects in cpp
classes & objects in cppgourav kottawar
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Abu Saleh
 
constructors and destructors
constructors and destructorsconstructors and destructors
constructors and destructorsAkshaya Parida
 
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12Abu Saleh
 
Friend this-new&delete
Friend this-new&deleteFriend this-new&delete
Friend this-new&deleteShehzad Rizwan
 
Chapter22 static-class-member-example
Chapter22 static-class-member-exampleChapter22 static-class-member-example
Chapter22 static-class-member-exampleDeepak Singh
 
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCECONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCEVenugopalavarma Raja
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Abu Saleh
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptishan743441
 
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco SlotDistributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco SlotCitus Data
 
unit-2 part-1.pptx
unit-2 part-1.pptxunit-2 part-1.pptx
unit-2 part-1.pptxmegana10
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and DestructorsKeyur Vadodariya
 
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo KumperaAdvanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo KumperaXamarin
 
CS Project-Source code for shopping inventory for CBSE 12th
CS Project-Source code for shopping inventory for CBSE 12thCS Project-Source code for shopping inventory for CBSE 12th
CS Project-Source code for shopping inventory for CBSE 12thSudhindra Mudhol
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEHitesh Mohapatra
 

Semelhante a classes & objects in cpp overview (20)

classes & objects in cpp
classes & objects in cppclasses & objects in cpp
classes & objects in cpp
 
Unit 2
Unit 2Unit 2
Unit 2
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
 
Constructor,destructors cpp
Constructor,destructors cppConstructor,destructors cpp
Constructor,destructors cpp
 
Class and object C++.pptx
Class and object C++.pptxClass and object C++.pptx
Class and object C++.pptx
 
constructors and destructors
constructors and destructorsconstructors and destructors
constructors and destructors
 
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
 
Friend this-new&delete
Friend this-new&deleteFriend this-new&delete
Friend this-new&delete
 
OOPS 22-23 (1).pptx
OOPS 22-23 (1).pptxOOPS 22-23 (1).pptx
OOPS 22-23 (1).pptx
 
Chapter22 static-class-member-example
Chapter22 static-class-member-exampleChapter22 static-class-member-example
Chapter22 static-class-member-example
 
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCECONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.ppt
 
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco SlotDistributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
 
unit-2 part-1.pptx
unit-2 part-1.pptxunit-2 part-1.pptx
unit-2 part-1.pptx
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo KumperaAdvanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
 
CS Project-Source code for shopping inventory for CBSE 12th
CS Project-Source code for shopping inventory for CBSE 12thCS Project-Source code for shopping inventory for CBSE 12th
CS Project-Source code for shopping inventory for CBSE 12th
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
 

Mais de gourav kottawar

operator overloading & type conversion in cpp
operator overloading & type conversion in cppoperator overloading & type conversion in cpp
operator overloading & type conversion in cppgourav kottawar
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cppgourav kottawar
 
working file handling in cpp overview
working file handling in cpp overviewworking file handling in cpp overview
working file handling in cpp overviewgourav kottawar
 
pointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpppointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cppgourav kottawar
 
exception handling in cpp
exception handling in cppexception handling in cpp
exception handling in cppgourav kottawar
 
cpp input & output system basics
cpp input & output system basicscpp input & output system basics
cpp input & output system basicsgourav kottawar
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++gourav kottawar
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cppgourav kottawar
 
SQL || overview and detailed information about Sql
SQL || overview and detailed information about SqlSQL || overview and detailed information about Sql
SQL || overview and detailed information about Sqlgourav kottawar
 
SQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesSQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesgourav kottawar
 
Rrelational algebra in dbms overview
Rrelational algebra in dbms overviewRrelational algebra in dbms overview
Rrelational algebra in dbms overviewgourav kottawar
 
overview of database concept
overview of database conceptoverview of database concept
overview of database conceptgourav kottawar
 
Relational Model in dbms & sql database
Relational Model in dbms & sql databaseRelational Model in dbms & sql database
Relational Model in dbms & sql databasegourav kottawar
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptgourav kottawar
 
security and privacy in dbms and in sql database
security and privacy in dbms and in sql databasesecurity and privacy in dbms and in sql database
security and privacy in dbms and in sql databasegourav kottawar
 
The system development life cycle (SDLC)
The system development life cycle (SDLC)The system development life cycle (SDLC)
The system development life cycle (SDLC)gourav kottawar
 

Mais de gourav kottawar (20)

operator overloading & type conversion in cpp
operator overloading & type conversion in cppoperator overloading & type conversion in cpp
operator overloading & type conversion in cpp
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
 
expression in cpp
expression in cppexpression in cpp
expression in cpp
 
basics of c++
basics of c++basics of c++
basics of c++
 
working file handling in cpp overview
working file handling in cpp overviewworking file handling in cpp overview
working file handling in cpp overview
 
pointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpppointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpp
 
exception handling in cpp
exception handling in cppexception handling in cpp
exception handling in cpp
 
cpp input & output system basics
cpp input & output system basicscpp input & output system basics
cpp input & output system basics
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
 
basics of c++
basics of c++basics of c++
basics of c++
 
expression in cpp
expression in cppexpression in cpp
expression in cpp
 
SQL || overview and detailed information about Sql
SQL || overview and detailed information about SqlSQL || overview and detailed information about Sql
SQL || overview and detailed information about Sql
 
SQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesSQL querys in detail || Sql query slides
SQL querys in detail || Sql query slides
 
Rrelational algebra in dbms overview
Rrelational algebra in dbms overviewRrelational algebra in dbms overview
Rrelational algebra in dbms overview
 
overview of database concept
overview of database conceptoverview of database concept
overview of database concept
 
Relational Model in dbms & sql database
Relational Model in dbms & sql databaseRelational Model in dbms & sql database
Relational Model in dbms & sql database
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) ppt
 
security and privacy in dbms and in sql database
security and privacy in dbms and in sql databasesecurity and privacy in dbms and in sql database
security and privacy in dbms and in sql database
 
The system development life cycle (SDLC)
The system development life cycle (SDLC)The system development life cycle (SDLC)
The system development life cycle (SDLC)
 

Último

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 

Último (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 

classes & objects in cpp overview

  • 1. Classes & Objects Chap 5 3/11/2016 1By:-Gourav Kottawar
  • 2. Contents 5.1 A Sample C++ Program with class 5.2 Access specifies 5.3 Defining Member Functions 5.4 Making an Outside Function Inline 5.5 Nesting of Member Functions 5.6 Private Member Functions 5.7 Arrays within a Class 5.8 Memory Allocation for Objects 5.9 Static Data Members, Static Member 5.10 Functions, Arrays of Objects 5.11 Object as Function Arguments 5.12 Friend Functions, Returning Objects, 5.13 Const member functions 5.14 Pointer to Members, Local Classes 5.15 Object composition & delegation 3/11/2016 2By:-Gourav Kottawar
  • 3. Declaring Class  Syntax – class class_name { private : variable declaration; function declaration; public: variable declaration; function declaration; } 3/11/2016 3By:-Gourav Kottawar
  • 4. Data hiding in classes 3/11/2016 4By:-Gourav Kottawar
  • 5. Simple class program Creating objects Accessing class members  Access specifies private public protector default - private  5.3 Defining Member Functions 3/11/2016 5By:-Gourav Kottawar
  • 6. 5.4 Making an Outside Function Inline class item { ...... ...... public: void getdata(int a,float b); }; inline void item :: getdata(int a,float b) { number=a; cost=b; } 3/11/2016 6By:-Gourav Kottawar
  • 7. 5.5 Nesting of Member Functions #include<iostream.h> #include<conio.h> class data { int rollno,maths,science; int avg(); public: void getdata(); void putdata(); }; main() { clrscr(); data stud[5]; for(int i=0;i<5;i++) stud[i].getdata(); } void data::getdata() { cout<<"Please enter rollno:"; cin>>rollno; cout<<"Please enter maths marks:"; cin>>maths; cout<<"Please enter science marks:"; cin>>science; putdata(); } int data::avg() { int a; a=(maths+science)/2; return a; } void data::putdata() { cout<<"Average is :"<<avg()<<endl; } 3/11/2016 7By:-Gourav Kottawar
  • 8. 5.7 Arrays within a Class const int size=10; class array { int a[size]; public: void setval(void); void display(void); }; 3/11/2016 8By:-Gourav Kottawar
  • 9. Ex- #include<iostream> #include<string> using namespace std; const int val=50; class ITEM { private: int item_code[val]; int item_price[val]; int count; public: void initiliaze(); void get_item(); void display_item(); void display_sum(); void remove(); }; void ITEM::initiliaze() { count=0; } void ITEM::get_item() { cout<<"Enter the Item code == "<<endl; cin>>item_code[count]; cout<<"Enter the Item cost == "<<endl; cin>>item_price[count]; count++; } void ITEM::display_sum() { int sum=0; for(int i=0; i<count;i++) { sum=sum + item_price[i]; } cout<<"The Total Value Of The Cost Is == "<<sum<<endl; } 3/11/2016 9By:-Gourav Kottawar
  • 10. void ITEM::display_item() { cout<<"nCode Pricen"; for(int k=0;k<count;k++) { cout<<"n"<<item_code[k]; cout<<" "<<item_price[k]; } } void ITEM::remove() { int del; cout<<"Enter the code you want to remove == "; cin>>del; for(int search=0; search<count; search++) { if(del == item_code[search]) { item_price[search]=0; item_code[search]=0; } } } 3/11/2016 10By:-Gourav Kottawar
  • 11. int main() { ITEM order; order.initiliaze(); int x; do { cout<<"nnYou have the following opton"; cout<<"nEnter the Appropriate number"; cout<<"nnPress 1 for ADD AN ITEMS"; cout<<"nnPress 2 for DISPLAY TOTAL VALUE"; cout<<"nnPress 3 for DELETE AN ITEM"; cout<<"nnPress 4 for DISPLAY ALL ITEMS"; cout<<"nnPress 5 for QUIT"; cout<<"nEnter The Desired Number == n"; cin>>x; switch(x) { case 1: { order.get_item(); break; } case 2: { order.display_sum(); break; } case 3: { order.remove(); break; } case 4: { order.display_item(); break; } 3/11/2016 11By:-Gourav Kottawar
  • 12. case 5: break; default: cout<<"Incorrect option Please Press the right number == "; } }while(x!=5); getchar(); return 0; } 3/11/2016 12By:-Gourav Kottawar
  • 13. 5.8 Memory Allocation for Objects common for all objects member function 1 member function 2 memory created when function defined Object 1 object 2 object 3 Member varible 1 member variable 2 member variable 1 Member variable 2 member variable 2 member variable 2 memory created when objects defined 3/11/2016 13By:-Gourav Kottawar
  • 14. 5.9 Static Data Members, Static Member  A data member of a class can be qualified as static.  The properties of a static member variable are similar to that of a C static variable.  It is initialized to zero when the first object of its class is created. No other initialization is permitted.  Only one copy of that member is created for the entire class and is shared by all the objects of that class, no matter how many objects are created.  It is visible only within the class, but its lifetime is the entire program. 3/11/2016 14By:-Gourav Kottawar
  • 15. #include using namespace std; class item { static int count; int number; public: void getdata(int a) { number = a; count ++; } void getcount(void) { cout << "Count: "; cout << count <<"n"; } }; int item :: count; int main() { item a,b,c; a.getcount(); b.getcount(); c.getcount(); a.getdata(100); b.getdata(200); c.getdata(300); cout << "After reading data"<<"n"; a.getcount(); b.getcount(); c.getcount(); return 0; } 3/11/2016 15By:-Gourav Kottawar
  • 16. #include using namespace std; class item { static int count; int number; public: void getdata(int a) { number = a; count ++; } void getcount(void) { cout << "Count: "; cout << count <<"n"; } }; int item :: count; int main() { item a,b,c; a.getcount(); b.getcount(); c.getcount(); a.getdata(100); b.getdata(200); c.getdata(300); cout << "After reading data"<<"n"; a.getcount(); b.getcount(); c.getcount(); return 0; } The output of the program would be: Count: 0 Count: 0 Count: 0 After reading data Count: 3 Count: 3 Count: 3 3/11/2016 16By:-Gourav Kottawar
  • 17. Sharing of a static data member 3/11/2016 17By:-Gourav Kottawar
  • 18. Static member function  A member function that is declared static has following properties 1. A static function can have access to only other static members (functions or variables) declared in the same class. 2. A static member function can be called using the class name (instead of its objects ) as follows : class – name :: function – name;3/11/2016 18By:-Gourav Kottawar
  • 19. 3/11/2016 19 class Something { private: static int s_nValue; public: static int GetValue() { return s_nValue; } }; int Something::s_nValue = 1; // initializer int main() { std::cout << Something::GetValue() << std::endl; } By:-Gourav Kottawar
  • 20. 3/11/2016 20 class IDGenerator { private: static int s_nNextID; public: static int GetNextID() { return s_nNextID++; } }; // We'll start generating IDs at 1 int IDGenerator::s_nNextID = 1; int main() { for (int i=0; i < 5; i++) cout << "The next ID is: " << IDGenerator::GetNextID() << endl; return 0; } The next ID is: 1 The next ID is: 2 The next ID is: 3 The next ID is: 4 The next ID is: 5 By:-Gourav Kottawar
  • 21. 3/11/2016 21 class IDGenerator { private: static int s_nNextID; public: static int GetNextID() { return s_nNextID++; } }; // We'll start generating IDs at 1 int IDGenerator::s_nNextID = 1; int main() { for (int i=0; i < 5; i++) cout << "The next ID is: " << IDGenerator::GetNextID() << endl; return 0; } By:-Gourav Kottawar
  • 22. Array of object 3/11/2016 22By:-Gourav Kottawar
  • 23. 5.11 Object as Function Arguments  Two ways 1. A copy of the entire object is passed to the function. i.e. pass by value 2. Only the address of the object is transferred to the function i.e. pass by reference 3/11/2016 23By:-Gourav Kottawar
  • 25. 3/11/2016 25 #include <iostream> using namespace std; class Complex { private: int real; int imag; public: void Read() { cout<<"Enter real and imaginary number respectively:"<<endl; cin>>real>>imag; } void Add(Complex comp1,Complex comp2) { real=comp1.real+comp2.real; /* Here, real represents the real data of object c3 because this function is called using code c3.add(c1,c2); */ imag=comp1.imag+comp2.imag; /* Here, imag represents the imag data of object c3 because this function is called using code c3.add(c1,c2); */ } By:-Gourav Kottawar
  • 26. 3/11/2016 26 void Display() { cout<<"Sum="<<real<<"+"<<imag<<"i"; } }; int main() { Complex c1,c2,c3; c1.Read(); c2.Read(); c3.Add(c1,c2); c3.Display(); return 0; } By:-Gourav Kottawar
  • 27. Returning Object from Function 3/11/2016 27By:-Gourav Kottawar
  • 28. 3/11/2016 28 #include <iostream> using namespace std; class Complex { private: int real; int imag; public: void Read() { cout<<"Enter real and imaginary number respectively:"<<endl; cin>>real>>imag; } Complex Add(Complex comp2) { Complex temp; temp.real=real+comp2.real; /* Here, real represents the real data of object c1 because this function is called using code c1.Add(c2) */ temp.imag=imag+comp2.imag; /* Here, imag represents the imag data of object c1 because this function is called using code c1.Add(c2) */ return temp; 0; } By:-Gourav Kottawar
  • 29. 3/11/2016 29 } void Display() { cout<<"Sum="<<real<<"+"<<ima g<<"i"; } }; int main() { Complex c1,c2,c3; c1.Read(); c2.Read(); c3=c1.Add(c2); c3.Display(); return 0; } By:-Gourav Kottawar
  • 30. 5.12 Friend function  Need a data is declared as private inside a class, then it is not accessible from outside the class. A function that is not a member or an external class will not be able to access the private data. A programmer may have a situation where he or she would need to access private data from non-member functions and external classes. For handling such cases, the concept of Friend functions is a useful tool. 3/11/2016 30By:-Gourav Kottawar
  • 31. 5.12 Friend function What is a Friend Function?  A friend function is used for accessing the non-public members of a class.  A class can allow non- member functions and other classes to access its own private data, by making them friends.  Thus, a friend function is an ordinary function or a member of another class. 3/11/2016 31By:-Gourav Kottawar
  • 32. 5.12 Friend function  General syntax Class ABC { ….. ….. public : ….. ….. Friend void func1(void); }; 3/11/2016 32By:-Gourav Kottawar
  • 33. 5.12 Friend function Special Characteristics  The keyword friend is placed only in the function declaration of the friend function and not in the function definition.  It is not in the scope of the class to which it has been declared as friend.  It is possible to declare a function as friend in any number of classes.  When a class is declared as a friend, the friend class has access to the private data of the class that made this a friend.  A friend function, even though it is not a member function, would have the rights to access the private members of the class.  It is possible to declare the friend function as either private or public without affecting meaning.  The function can be invoked without the use of an object.  It has object as argument. 3/11/2016 33By:-Gourav Kottawar
  • 34. 3/11/2016 34 #include <iostream> using namespace std; class exforsys { private: int a,b; public: void test() { a=100; b=200; } friend int compute(exforsys e1); //Friend Function Declaration with keyword friend and with the object of class exforsys to which it is friend passed to it }; int compute(exforsys e1) { //Friend Function Definition which has access to private data return int(e1.a+e1.b)-5; } void main() { exforsys e; e.test(); cout << "The result is:" << compute(e); //Calling of Friend Function with object as argument. } By:-Gourav Kottawar
  • 35. Constant Member Functions  Declaring a member function with the const keyword specifies that the function is a "read-only" function that does not modify the object for which it is called.  A constantmember function cannot modify any non-static data members or call any member functions that aren't constant.  The const keyword is required in both the declaration and the definition. 3/11/2016 35By:-Gourav Kottawar
  • 36. Constant Member Functions – EXclass Date { public: Date( int mn, int dy, int yr ); int getMonth() const; // A read-only function void setMonth( int mn ); // A write function; can't be const private: int month; }; int Date::getMonth() const { return month; // Doesn't modify anything } 3/11/2016 36 void Date::setMonth( int mn ) { month = mn; // Modifies data member } int main() { Date MyDate( 7, 4, 1998 ); const Date BirthDate( 1, 18, 1953 ); MyDate.setMonth( 4 ); // Okay BirthDate.getMonth(); // Okay BirthDate.setMonth( 4 ); // C2662 Error } By:-Gourav Kottawar
  • 37. 5.14 Pointers to members  Pointers to members allow you to refer to nonstatic members of class objects.  You cannot use a pointer to member to point to a static class member because the address of a static member is not associated with any particular object.  To point to a static class member, you must use a normal pointer.  You can use pointers to member functions in the same manner as pointers to functions.  You can compare pointers to member functions, assign values to them, and use them to call member functions.  Note - a member function does not have the same type as a nonmember function that has the same number and type of arguments and the same return type. 3/11/2016 37By:-Gourav Kottawar
  • 38. 5.14 Pointers to members - Ex #include <iostream> using namespace std; class X { public: int a; void f(int b) { cout << "The value of b is "<< b << endl; } }; 3/11/2016 38 int main() { // declare pointer to data member int X::*ptiptr = &X::a; // declare a pointer to member function void (X::* ptfptr) (int) = &X::f; // create an object of class type X X xobject; // initialize data member xobject.*ptiptr = 10; cout << "The value of a is " << xobject.*ptiptr << endl; // call member function (xobject.*ptfptr) (20); } By:-Gourav Kottawar
  • 39. 5.14 Local Classes  A local class is declared within a function definition.  Declarations in a local class can only use type names, enumerations, static variables from the enclosing scope, as well as external variables and functions.  Member functions of a local class have to be defined within their class definition, if they are defined at all.  As a result, member functions of a local class are inline functions. Like all member functions, those defined within the scope of a local class do not need the keyword inline. 3/11/2016 39By:-Gourav Kottawar
  • 40. 3/11/2016 40 int x; // global variable void f() // function definition { static int y; // static variable y can be used by local class int x; // auto variable x cannot be used by local class extern int g(); // extern function g can be used by local class class local // local class { int g() { return x; } // error, local variable x // cannot be used by g int h() { return y; } // valid,static variable y int k() { return ::x; } // valid, global x int l() { return g(); } // valid, extern function g }; } int main() { local* z; // error: the class local is not visible // ...} By:-Gourav Kottawar
  • 41. 3/11/2016 41 A local class cannot have static data members. void f() { class local { int f(); // error, local class has noninline // member function int g() {return 0;} // valid, inline member function static int a; // error, static is not allowed for // local class int b; // valid, nonstatic variable }; } // . . . By:-Gourav Kottawar