SlideShare a Scribd company logo
Duhok Polytechnic UniversityDuhok Polytechnic University
Akre Technical InstituteAkre Technical Institute
IT DepartmentIT Department
Seminar AboutSeminar About
OOP COOP C##
Supervision:Supervision: Prepared By:Prepared By:
2014 -20152014 -2015
11
Object Oriented ProgrammingObject Oriented Programming
 ProgrammerProgrammer thinksthinks about and defines theabout and defines the
attributes and behavior of objects.attributes and behavior of objects.
 Often the objects are modeled after real-Often the objects are modeled after real-
world entities.world entities.
 Very different approach thanVery different approach than function-basedfunction-based
programming (like C).programming (like C).
Object Oriented ProgrammingObject Oriented Programming
 Object-oriented programming (OOP)Object-oriented programming (OOP)
– Encapsulates data (attributes) and functionsEncapsulates data (attributes) and functions
(behavior) into packages called classes.(behavior) into packages called classes.
 So, Classes are user-defined (programmer-So, Classes are user-defined (programmer-
defined) types.defined) types.
– Data (data members)Data (data members)
– Functions (member functions or methods)Functions (member functions or methods)
 In other words, they are structures +In other words, they are structures +
functionsfunctions
Reasons for OOPReasons for OOP
1.1. Simplify programmingSimplify programming
2.2. InterfacesInterfaces
 Information hiding:Information hiding:
– Implementation details hidden within classes themselvesImplementation details hidden within classes themselves
1.1. Software reuseSoftware reuse
 Class objects included as members of otherClass objects included as members of other
classesclasses
1- Access Modifiers (Access Specifiers)1- Access Modifiers (Access Specifiers)
describes as the scope of accessibility of an
Object and its members. All C# types and
type members have an accessibility level . We
can control the scope of the member object of
a class using access specifiers. We are using
access modifiers for providing security of our
applications. When we specify the
accessibility of a type or member we have to
declare it by using any of the access modifiers
provided by CSharp language.
public :
public is the most common access specifier in
C# . It can be access from anywhere, that
means there is no restriction on accessibility.
The scope of the accessibility is inside class
as well as outside. The type or member can
be accessed by any other code in the same
assembly or another assembly that
references it.
private :
The scope of the accessibility is limited only
inside the classes or struct in which they are
protected :
The scope of accessibility is limited within the
class or struct and the class derived (Inherited
)from this class.
internal :
The internal access modifiers can access
within the program that contain its
declarations and also access within the same
assembly level but not from another
assembly.
protected internal :
Protected internal is the same access levels
2- Constructors and
destructors
Constructors are special methods, used when
instantiating a class. A constructor can never
return anything, which is why you don't have
to define a return type for it. A normal method
is defined like this:
public string Describe()
A constructor can be defined like this:
public Car()
In our example for this chapter, we have a Car
{
}
public Car(string color)
{
this.color = color;
}
A constructor can call another constructor, which can come in
handy in several situations. Here is an example:
public Car()
{
Console.WriteLine("Constructor with no
parameters called!");
}
public Car(string color) : this()
{
this.color = color;
Console.WriteLine("Constructor with color
parameter called!");
If you run this code, you will see that the
constructor with no parameters is called first.
This can be used for instantiating various
objects for the class in the default constructor,
which can be called from other constructors
from the class. If the constructor you wish to
call takes parameters, you can do that as well.
Here is a simple example:
 public Car(string color) : this()
 {
 this.color = color;
 Console.WriteLine("Constructor with color
parameter called!");
 }

 public Car(string param1, string param2) :
this(param1)
 {

 }
 If you call the constructor which takes 2
DestructorsDestructors
Since C# is garbage collected, meaing that
the framework will free the objects that you no
longer use, there may be times where you
need to do some manual cleanup. A
destructor, a method called once an object is
disposed, can be used to cleanup resources
used by the object. Destructors doesn't look
very much like other methods in C#. Here is
an example of a destructor for our Car class:
~Car()
3-
C# - Copy Constructor in C# with Ex
 Introduction:
 Here I will explain what is copy constructor
in c# with example. Copy constructor in c#
is used to create new instance to the
values of an existing instance
 Description:
 In previous posts I explained
create captcha with refresh button in asp.net
,
use of virtual, override and new keyword with e
, method overloading and overriding,
delegates example in c#, sealed class in c#
, using statement in c#,
OOPS examples in c# and many articles
relating to interview questions in c#
, asp.net, SQL server, JavaScript, jQuery.
Now I will explain copy constructor
Copy Constructor
A parameterized constructor that contains a
parameter of same class type is called as
copy constructor. Main purpose of copy
constructor is to initialize new instance to the
values of an existing instance. Check below
example for this
using System;
namespace ConsoleApplication3
{
class Sample
{
public string param1, param2;
public Sample(string x, string y)
{
param1 = x;
param2 = y;
}
public Sample(Sample obj)     //  Copy 
4-Friend Functions
A friend function  is  a  function  that  is  not  a 
member  of  a  class  but  has  access  to  the 
class's private and protected members. Friend 
functions are not considered class members; 
they  are  normal  external  functions  that  are 
given  special  access  privileges.  Friends  are 
not  in  the  class's  scope,  and  they  are  not 
called  using  the  member-selection  operators 
(.and –>) unless they are members of another 
class.  A friend function  is  declared  by  the 
Example
// friend_functions.cpp
// compile with: /EHsc
#include <iostream>
 
using namespace std;
class Point
{
    friend void ChangePrivate( Point & );
public:
    Point( void ) : m_i(0) {}
1919
ReferenceReference
 R. C. Gonzolez, R. E. Woods, "Digital Image Processing R. C. Gonzolez, R. E. Woods, "Digital Image Processing 
second edition", Prentice Hall, 2002.second edition", Prentice Hall, 2002.
 R.  C.  Gonzolez,  R.  E.  Woods,  S.  L.  Eddins,  "Digital R.  C.  Gonzolez,  R.  E.  Woods,  S.  L.  Eddins,  "Digital 
Image Processing Using Matlab", Prentice Hall, 2004.Image Processing Using Matlab", Prentice Hall, 2004.
 T. Acharya, A. K. Ray, "Image Processing: Principles and T. Acharya, A. K. Ray, "Image Processing: Principles and 
Applications", John Wiley & Sons, 2005.Applications", John Wiley & Sons, 2005.
 B.  E.  Usevitch,  'A  Tutorial  on  Modern  Lossy  Wavelet B.  E.  Usevitch,  'A  Tutorial  on  Modern  Lossy  Wavelet 
Image Compression: Foundations of  JPEG 2000',  IEEE Image Compression: Foundations of  JPEG 2000',  IEEE 
Signal  Processing  Magazine,  vol.  18,  pp.  22-35,  Sept. Signal  Processing  Magazine,  vol.  18,  pp.  22-35,  Sept. 
2001. 2001. 

More Related Content

What's hot (20)

PDF
Constructors and destructors
Prof. Dr. K. Adisesha
 
PPTX
Structure of java program diff c- cpp and java
Madishetty Prathibha
 
PPT
Java interfaces
Raja Sekhar
 
PPTX
C# lecture 1: Introduction to Dot Net Framework
Dr.Neeraj Kumar Pandey
 
PPT
Interfaces In Java
parag
 
PPT
Chapter 9 Interface
OUM SAOKOSAL
 
PPTX
Chapter 06 constructors and destructors
Praveen M Jigajinni
 
PDF
A COMPLETE FILE FOR C++
M Hussnain Ali
 
PPT
Dot net introduction
Dr.Neeraj Kumar Pandey
 
DOC
My c++
snathick
 
PDF
Class and object
Prof. Dr. K. Adisesha
 
PPT
C++ Interview Questions
Kaushik Raghupathi
 
PPT
Virtual Function
Lovely Professional University
 
PPTX
Learn Concept of Class and Object in C# Part 3
C# Learning Classes
 
PDF
Object Oriented Programming With C++
Vishnu Shaji
 
PPTX
Java interface
Md. Tanvir Hossain
 
PPTX
Object oriented programming in java
Elizabeth alexander
 
PPTX
Inheritance, friend function, virtual function, polymorphism
Jawad Khan
 
PDF
Function overloading
Prof. Dr. K. Adisesha
 
PDF
Inheritance
Prof. Dr. K. Adisesha
 
Constructors and destructors
Prof. Dr. K. Adisesha
 
Structure of java program diff c- cpp and java
Madishetty Prathibha
 
Java interfaces
Raja Sekhar
 
C# lecture 1: Introduction to Dot Net Framework
Dr.Neeraj Kumar Pandey
 
Interfaces In Java
parag
 
Chapter 9 Interface
OUM SAOKOSAL
 
Chapter 06 constructors and destructors
Praveen M Jigajinni
 
A COMPLETE FILE FOR C++
M Hussnain Ali
 
Dot net introduction
Dr.Neeraj Kumar Pandey
 
My c++
snathick
 
Class and object
Prof. Dr. K. Adisesha
 
C++ Interview Questions
Kaushik Raghupathi
 
Learn Concept of Class and Object in C# Part 3
C# Learning Classes
 
Object Oriented Programming With C++
Vishnu Shaji
 
Java interface
Md. Tanvir Hossain
 
Object oriented programming in java
Elizabeth alexander
 
Inheritance, friend function, virtual function, polymorphism
Jawad Khan
 
Function overloading
Prof. Dr. K. Adisesha
 

Viewers also liked (11)

PPT
C++ tutorials
Divyanshu Dubey
 
PDF
Основы ооп на языке C#. Часть 2. базовый синтаксис.
YakubovichDA
 
PDF
основы ооп на языке C#. часть 1. введение в программирование
YakubovichDA
 
PDF
Web-программирование и жизнь.
Alex Mamonchik
 
PPT
C++ classes tutorials
kailash454
 
PPTX
Обобщенные классы в C#
REX-MDK
 
PDF
Лекция #6. Введение в Django web-framework
Яковенко Кирилл
 
PDF
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
PDF
Лекция #4. Каскадные таблицы стилей
Яковенко Кирилл
 
PPT
Programming in c
indra Kishor
 
PDF
10 tips for learning Russian
Steve Kaufmann
 
C++ tutorials
Divyanshu Dubey
 
Основы ооп на языке C#. Часть 2. базовый синтаксис.
YakubovichDA
 
основы ооп на языке C#. часть 1. введение в программирование
YakubovichDA
 
Web-программирование и жизнь.
Alex Mamonchik
 
C++ classes tutorials
kailash454
 
Обобщенные классы в C#
REX-MDK
 
Лекция #6. Введение в Django web-framework
Яковенко Кирилл
 
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
Лекция #4. Каскадные таблицы стилей
Яковенко Кирилл
 
Programming in c
indra Kishor
 
10 tips for learning Russian
Steve Kaufmann
 
Ad

Similar to C++ classes tutorials (20)

PDF
OOPs Interview Questions PDF By ScholarHat
Scholarhat
 
DOCX
csharp.docx
LenchoMamudeBaro
 
PDF
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
 
PDF
C Sharp: Basic to Intermediate Part 01
Zafor Iqbal
 
DOCX
Java interview questions and answers
Krishnaov
 
DOCX
I assignmnt(oops)
Jay Patel
 
PPTX
Php oop (1)
Sudip Simkhada
 
PDF
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
PPTX
C# classes objects
Dr.Neeraj Kumar Pandey
 
PPT
Oops concepts in php
CPD INDIA
 
PPTX
classes object fgfhdfgfdgfgfgfgfdoop.pptx
arjun431527
 
PDF
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
PPTX
C++ Object Oriented Programming
Gamindu Udayanga
 
PPTX
Interoduction to c++
Amresh Raj
 
PPTX
OOPS IN PHP.pptx
rani marri
 
PPTX
Learn C# Programming - Encapsulation & Methods
Eng Teong Cheah
 
DOCX
Java notes
Upasana Talukdar
 
PPTX
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
PPTX
Presentation 3rd
Connex
 
PPTX
Object-oriented programming 3.pptx
Adikhan27
 
OOPs Interview Questions PDF By ScholarHat
Scholarhat
 
csharp.docx
LenchoMamudeBaro
 
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
 
C Sharp: Basic to Intermediate Part 01
Zafor Iqbal
 
Java interview questions and answers
Krishnaov
 
I assignmnt(oops)
Jay Patel
 
Php oop (1)
Sudip Simkhada
 
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
C# classes objects
Dr.Neeraj Kumar Pandey
 
Oops concepts in php
CPD INDIA
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
arjun431527
 
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
C++ Object Oriented Programming
Gamindu Udayanga
 
Interoduction to c++
Amresh Raj
 
OOPS IN PHP.pptx
rani marri
 
Learn C# Programming - Encapsulation & Methods
Eng Teong Cheah
 
Java notes
Upasana Talukdar
 
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
Presentation 3rd
Connex
 
Object-oriented programming 3.pptx
Adikhan27
 
Ad

Recently uploaded (20)

PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
July Patch Tuesday
Ivanti
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
July Patch Tuesday
Ivanti
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 

C++ classes tutorials

  • 1. Duhok Polytechnic UniversityDuhok Polytechnic University Akre Technical InstituteAkre Technical Institute IT DepartmentIT Department Seminar AboutSeminar About OOP COOP C## Supervision:Supervision: Prepared By:Prepared By: 2014 -20152014 -2015 11
  • 2. Object Oriented ProgrammingObject Oriented Programming  ProgrammerProgrammer thinksthinks about and defines theabout and defines the attributes and behavior of objects.attributes and behavior of objects.  Often the objects are modeled after real-Often the objects are modeled after real- world entities.world entities.  Very different approach thanVery different approach than function-basedfunction-based programming (like C).programming (like C).
  • 3. Object Oriented ProgrammingObject Oriented Programming  Object-oriented programming (OOP)Object-oriented programming (OOP) – Encapsulates data (attributes) and functionsEncapsulates data (attributes) and functions (behavior) into packages called classes.(behavior) into packages called classes.  So, Classes are user-defined (programmer-So, Classes are user-defined (programmer- defined) types.defined) types. – Data (data members)Data (data members) – Functions (member functions or methods)Functions (member functions or methods)  In other words, they are structures +In other words, they are structures + functionsfunctions
  • 4. Reasons for OOPReasons for OOP 1.1. Simplify programmingSimplify programming 2.2. InterfacesInterfaces  Information hiding:Information hiding: – Implementation details hidden within classes themselvesImplementation details hidden within classes themselves 1.1. Software reuseSoftware reuse  Class objects included as members of otherClass objects included as members of other classesclasses
  • 5. 1- Access Modifiers (Access Specifiers)1- Access Modifiers (Access Specifiers) describes as the scope of accessibility of an Object and its members. All C# types and type members have an accessibility level . We can control the scope of the member object of a class using access specifiers. We are using access modifiers for providing security of our applications. When we specify the accessibility of a type or member we have to declare it by using any of the access modifiers provided by CSharp language.
  • 6. public : public is the most common access specifier in C# . It can be access from anywhere, that means there is no restriction on accessibility. The scope of the accessibility is inside class as well as outside. The type or member can be accessed by any other code in the same assembly or another assembly that references it. private : The scope of the accessibility is limited only inside the classes or struct in which they are
  • 7. protected : The scope of accessibility is limited within the class or struct and the class derived (Inherited )from this class. internal : The internal access modifiers can access within the program that contain its declarations and also access within the same assembly level but not from another assembly. protected internal : Protected internal is the same access levels
  • 8. 2- Constructors and destructors Constructors are special methods, used when instantiating a class. A constructor can never return anything, which is why you don't have to define a return type for it. A normal method is defined like this: public string Describe() A constructor can be defined like this: public Car() In our example for this chapter, we have a Car
  • 9. { } public Car(string color) { this.color = color; } A constructor can call another constructor, which can come in handy in several situations. Here is an example: public Car() { Console.WriteLine("Constructor with no parameters called!"); } public Car(string color) : this() { this.color = color; Console.WriteLine("Constructor with color parameter called!");
  • 10. If you run this code, you will see that the constructor with no parameters is called first. This can be used for instantiating various objects for the class in the default constructor, which can be called from other constructors from the class. If the constructor you wish to call takes parameters, you can do that as well. Here is a simple example:
  • 11.  public Car(string color) : this()  {  this.color = color;  Console.WriteLine("Constructor with color parameter called!");  }   public Car(string param1, string param2) : this(param1)  {   }  If you call the constructor which takes 2
  • 12. DestructorsDestructors Since C# is garbage collected, meaing that the framework will free the objects that you no longer use, there may be times where you need to do some manual cleanup. A destructor, a method called once an object is disposed, can be used to cleanup resources used by the object. Destructors doesn't look very much like other methods in C#. Here is an example of a destructor for our Car class: ~Car()
  • 13. 3- C# - Copy Constructor in C# with Ex  Introduction:  Here I will explain what is copy constructor in c# with example. Copy constructor in c# is used to create new instance to the values of an existing instance
  • 14.  Description:  In previous posts I explained create captcha with refresh button in asp.net , use of virtual, override and new keyword with e , method overloading and overriding, delegates example in c#, sealed class in c# , using statement in c#, OOPS examples in c# and many articles relating to interview questions in c# , asp.net, SQL server, JavaScript, jQuery. Now I will explain copy constructor
  • 15. Copy Constructor A parameterized constructor that contains a parameter of same class type is called as copy constructor. Main purpose of copy constructor is to initialize new instance to the values of an existing instance. Check below example for this
  • 17. 4-Friend Functions A friend function  is  a  function  that  is  not  a  member  of  a  class  but  has  access  to  the  class's private and protected members. Friend  functions are not considered class members;  they  are  normal  external  functions  that  are  given  special  access  privileges.  Friends  are  not  in  the  class's  scope,  and  they  are  not  called  using  the  member-selection  operators  (.and –>) unless they are members of another  class.  A friend function  is  declared  by  the 
  • 19. 1919 ReferenceReference  R. C. Gonzolez, R. E. Woods, "Digital Image Processing R. C. Gonzolez, R. E. Woods, "Digital Image Processing  second edition", Prentice Hall, 2002.second edition", Prentice Hall, 2002.  R.  C.  Gonzolez,  R.  E.  Woods,  S.  L.  Eddins,  "Digital R.  C.  Gonzolez,  R.  E.  Woods,  S.  L.  Eddins,  "Digital  Image Processing Using Matlab", Prentice Hall, 2004.Image Processing Using Matlab", Prentice Hall, 2004.  T. Acharya, A. K. Ray, "Image Processing: Principles and T. Acharya, A. K. Ray, "Image Processing: Principles and  Applications", John Wiley & Sons, 2005.Applications", John Wiley & Sons, 2005.  B.  E.  Usevitch,  'A  Tutorial  on  Modern  Lossy  Wavelet B.  E.  Usevitch,  'A  Tutorial  on  Modern  Lossy  Wavelet  Image Compression: Foundations of  JPEG 2000',  IEEE Image Compression: Foundations of  JPEG 2000',  IEEE  Signal  Processing  Magazine,  vol.  18,  pp.  22-35,  Sept. Signal  Processing  Magazine,  vol.  18,  pp.  22-35,  Sept.  2001. 2001.