Enviar pesquisa
Carregar
Aae oop xp_07
•
3 gostaram
•
509 visualizações
Niit Care
Seguir
Tecnologia
Educação
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 25
Recomendados
Function notes
Function notes
Hitesh Wagle
C programming session 02
C programming session 02
AjayBahoriya
03 iec t1_s1_oo_ps_session_04
03 iec t1_s1_oo_ps_session_04
Niit Care
05 iec t1_s1_oo_ps_session_07
05 iec t1_s1_oo_ps_session_07
Niit Care
Functions
Functions
Mitali Chugh
Functions
Functions
Mitali Chugh
Constructors and destructors in C++
Constructors and destructors in C++
RAJ KUMAR
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objects
Rai University
Recomendados
Function notes
Function notes
Hitesh Wagle
C programming session 02
C programming session 02
AjayBahoriya
03 iec t1_s1_oo_ps_session_04
03 iec t1_s1_oo_ps_session_04
Niit Care
05 iec t1_s1_oo_ps_session_07
05 iec t1_s1_oo_ps_session_07
Niit Care
Functions
Functions
Mitali Chugh
Functions
Functions
Mitali Chugh
Constructors and destructors in C++
Constructors and destructors in C++
RAJ KUMAR
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objects
Rai University
12 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_17
Niit Care
Java concepts and questions
Java concepts and questions
Farag Zakaria
C++ rajan
C++ rajan
Deep Rajan
Ocs752 unit 5
Ocs752 unit 5
mgrameshmail
Datastructure notes
Datastructure notes
Srikanth
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
Niit Care
Web application architecture
Web application architecture
Ilio Catallo
Ocs752 unit 4
Ocs752 unit 4
mgrameshmail
Le langage rust
Le langage rust
Geeks Anonymes
2. data, operators, io
2. data, operators, io
Srichandan Sobhanayak
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture Notes
Sreedhar Chowdam
C Programming Language
C Programming Language
RTS Tech
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
Mansi Tyagi
Python-oop
Python-oop
RTS Tech
Virtual function
Virtual function
harman kaur
C Programming Storage classes, Recursion
C Programming Storage classes, Recursion
Sreedhar Chowdam
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
Sreedhar Chowdam
Cpp17 and Beyond
Cpp17 and Beyond
ComicSansMS
Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2
Naveen Kumar
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template Metaprograms
Platonov Sergey
Aae oop xp_08
Aae oop xp_08
Niit Care
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
Dudy Ali
Mais conteúdo relacionado
Mais procurados
12 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_17
Niit Care
Java concepts and questions
Java concepts and questions
Farag Zakaria
C++ rajan
C++ rajan
Deep Rajan
Ocs752 unit 5
Ocs752 unit 5
mgrameshmail
Datastructure notes
Datastructure notes
Srikanth
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
Niit Care
Web application architecture
Web application architecture
Ilio Catallo
Ocs752 unit 4
Ocs752 unit 4
mgrameshmail
Le langage rust
Le langage rust
Geeks Anonymes
2. data, operators, io
2. data, operators, io
Srichandan Sobhanayak
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture Notes
Sreedhar Chowdam
C Programming Language
C Programming Language
RTS Tech
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
Mansi Tyagi
Python-oop
Python-oop
RTS Tech
Virtual function
Virtual function
harman kaur
C Programming Storage classes, Recursion
C Programming Storage classes, Recursion
Sreedhar Chowdam
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
Sreedhar Chowdam
Cpp17 and Beyond
Cpp17 and Beyond
ComicSansMS
Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2
Naveen Kumar
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template Metaprograms
Platonov Sergey
Mais procurados
(20)
12 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_17
Java concepts and questions
Java concepts and questions
C++ rajan
C++ rajan
Ocs752 unit 5
Ocs752 unit 5
Datastructure notes
Datastructure notes
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
Web application architecture
Web application architecture
Ocs752 unit 4
Ocs752 unit 4
Le langage rust
Le langage rust
2. data, operators, io
2. data, operators, io
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture Notes
C Programming Language
C Programming Language
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
Python-oop
Python-oop
Virtual function
Virtual function
C Programming Storage classes, Recursion
C Programming Storage classes, Recursion
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
Cpp17 and Beyond
Cpp17 and Beyond
Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template Metaprograms
Semelhante a Aae oop xp_07
Aae oop xp_08
Aae oop xp_08
Niit Care
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
Dudy Ali
Constructors and Destructors
Constructors and Destructors
Keyur Vadodariya
PPT DMA.pptx
PPT DMA.pptx
Abhishekkumarsingh630054
Constructors in C++.pptx
Constructors in C++.pptx
Rassjb
14 operator overloading
14 operator overloading
Docent Education
P/Invoke - Interoperability of C++ and C#
P/Invoke - Interoperability of C++ and C#
Rainer Stropek
Functions
Functions
Munazza-Mah-Jabeen
Aae oop xp_03
Aae oop xp_03
Niit Care
C# Unit 2 notes
C# Unit 2 notes
Sudarshan Dhondaley
CiIC4010-chapter-2-f17
CiIC4010-chapter-2-f17
BienvenidoVelezUPR
Aae oop xp_13
Aae oop xp_13
Niit Care
Constructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdf
LadallaRajKumar
Java programming concept
Java programming concept
Sanjay Gunjal
Data structure week 1
Data structure week 1
karmuhtam
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
Manivannan837728
21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx
Anantjain234527
Dynamic memory allocation in c++
Dynamic memory allocation in c++
Tech_MX
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
Ajit Nayak
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Jamsher bhanbhro
Semelhante a Aae oop xp_07
(20)
Aae oop xp_08
Aae oop xp_08
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
Constructors and Destructors
Constructors and Destructors
PPT DMA.pptx
PPT DMA.pptx
Constructors in C++.pptx
Constructors in C++.pptx
14 operator overloading
14 operator overloading
P/Invoke - Interoperability of C++ and C#
P/Invoke - Interoperability of C++ and C#
Functions
Functions
Aae oop xp_03
Aae oop xp_03
C# Unit 2 notes
C# Unit 2 notes
CiIC4010-chapter-2-f17
CiIC4010-chapter-2-f17
Aae oop xp_13
Aae oop xp_13
Constructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdf
Java programming concept
Java programming concept
Data structure week 1
Data structure week 1
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx
Dynamic memory allocation in c++
Dynamic memory allocation in c++
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Mais de Niit Care
Ajs 1 b
Ajs 1 b
Niit Care
Ajs 4 b
Ajs 4 b
Niit Care
Ajs 4 a
Ajs 4 a
Niit Care
Ajs 4 c
Ajs 4 c
Niit Care
Ajs 3 b
Ajs 3 b
Niit Care
Ajs 3 a
Ajs 3 a
Niit Care
Ajs 3 c
Ajs 3 c
Niit Care
Ajs 2 b
Ajs 2 b
Niit Care
Ajs 2 a
Ajs 2 a
Niit Care
Ajs 2 c
Ajs 2 c
Niit Care
Ajs 1 a
Ajs 1 a
Niit Care
Ajs 1 c
Ajs 1 c
Niit Care
Dacj 4 2-c
Dacj 4 2-c
Niit Care
Dacj 4 2-b
Dacj 4 2-b
Niit Care
Dacj 4 2-a
Dacj 4 2-a
Niit Care
Dacj 4 1-c
Dacj 4 1-c
Niit Care
Dacj 4 1-b
Dacj 4 1-b
Niit Care
Dacj 4 1-a
Dacj 4 1-a
Niit Care
Dacj 1-2 b
Dacj 1-2 b
Niit Care
Dacj 1-3 c
Dacj 1-3 c
Niit Care
Mais de Niit Care
(20)
Ajs 1 b
Ajs 1 b
Ajs 4 b
Ajs 4 b
Ajs 4 a
Ajs 4 a
Ajs 4 c
Ajs 4 c
Ajs 3 b
Ajs 3 b
Ajs 3 a
Ajs 3 a
Ajs 3 c
Ajs 3 c
Ajs 2 b
Ajs 2 b
Ajs 2 a
Ajs 2 a
Ajs 2 c
Ajs 2 c
Ajs 1 a
Ajs 1 a
Ajs 1 c
Ajs 1 c
Dacj 4 2-c
Dacj 4 2-c
Dacj 4 2-b
Dacj 4 2-b
Dacj 4 2-a
Dacj 4 2-a
Dacj 4 1-c
Dacj 4 1-c
Dacj 4 1-b
Dacj 4 1-b
Dacj 4 1-a
Dacj 4 1-a
Dacj 1-2 b
Dacj 1-2 b
Dacj 1-3 c
Dacj 1-3 c
Último
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Martijn de Jong
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
hans926745
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Remote DBA Services
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
The Digital Insurer
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Safe Software
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Enterprise Knowledge
Evaluating the top large language models.pdf
Evaluating the top large language models.pdf
ChristopherTHyatt
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
naman860154
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Delhi Call girls
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
apidays
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
The Digital Insurer
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Gabriella Davis
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Anna Loughnan Colquhoun
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Radu Cotescu
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Miguel Araújo
Último
(20)
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Evaluating the top large language models.pdf
Evaluating the top large language models.pdf
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Aae oop xp_07
1.
Constructors and Destructors Objectives In
this lesson, you will learn to: Identify the need for constructors Declare constructors Identify the need for destructors Declare destructors Use scope resolution operator Use constructors with parameters Invoke member functions by using: The call by value method ©NIIT OOPS/Lesson 7/Slide 1 of 25
2.
Constructors and Destructors Objectives
(Contd.) The call by reference method ® Using alias ® Using pointer ©NIIT OOPS/Lesson 7/Slide 2 of 25
3.
Constructors and Destructors Constructors
Are used to initialize the member variables of the class when the objects of the class are created Must have the same name as that of class name Cannot return any value, not even a void type Class can have more than one constructors defined in it (known as overloaded constructors) Default constructors accept no parameters and are automatically invoked by the compiler ©NIIT OOPS/Lesson 7/Slide 3 of 25
4.
Constructors and Destructors Need
for Constructors To initialize a member variable at the time of declaration ©NIIT OOPS/Lesson 7/Slide 4 of 25
5.
Constructors and Destructors Declaration
of Constructors Example: class Calculator { private: int number1, number2, tot; public: ... Calculator() { number1 = number2 = tot = 0; cout Constructor invoked endl; } }; ©NIIT OOPS/Lesson 7/Slide 5 of 25
6.
Constructors and Destructors Destructors
Are used to de-initialize the objects when they are destroyed Are used to clear memory space occupied by a data member when an object goes out of scope Must have the same name as that of the class, preceded by a ~ (For example: ~Calculator()) Are automatically invoked Can also be explicitly invoked when required Cannot be overloaded ©NIIT OOPS/Lesson 7/Slide 6 of 25
7.
Constructors and Destructors Need
for Destructors To de-initialize the objects when they are destroyed To clear memory space occupied by a data member when an object goes out of scope ©NIIT OOPS/Lesson 7/Slide 7 of 25
8.
Constructors and Destructors Declaration
of Destructors Example: /* This Code Shows The Use Of Destructor In The Calculator Class */ class Calculator { private: int number1, number2, tot; public: ... ~Calculator() //Body Of The //Destructor { number1 = number2 = tot = 0; } }; ©NIIT OOPS/Lesson 7/Slide 8 of 25
9.
Constructors and Destructors Just
a Minute… Given is a code snippet for the main() function of a program. How would you ensure that the following tasks are accomplished when the program is executed: 1. The member variables are initialized with zero 2. On exit or termination of the program the following message is displayed : “Bye Folks!!! Have a Nice Time” #include iostream int main() { Number num1;num1.disp(); } Hint: The Number class has only one member variable ©NIIT myNum. OOPS/Lesson 7/Slide 9 of 25
10.
Constructors and Destructors Scope
Resolution Operator (::) Is used to define member functions outside the class definition therefore making the class definition more readable Example: class calculator { public: void input(); }; void calculator::input () {…} ©NIIT OOPS/Lesson 7/Slide 10 of 25
11.
Constructors and Destructors Constructors
with Parameters Allow member variables of the class to be initialized with user supplied values from main() function also called parameters Example class calculate { private: int num1,num2,total; public: calculate(int, int); }; ©NIIT OOPS/Lesson 7/Slide 11 of 25
12.
Constructors and Destructors Constructors
with Parameters (Contd.) calculate::calculate(int x, int y) { num1=x;num2=y; total=0; } int main() {//Accept values in two variable var1 //var2 calculate c1(var1,var2); } ©NIIT OOPS/Lesson 7/Slide 12 of 25
13.
Constructors and Destructors Invoking
Member Functions By using call by value By using call by reference ©NIIT OOPS/Lesson 7/Slide 13 of 25
14.
Constructors and Destructors Call
by Value Is useful when the function does not need to modify the values of the original variables Does not affect the values of the variables in caller functions ©NIIT OOPS/Lesson 7/Slide 14 of 25
15.
Constructors and Destructors Problem
Statement 5.P.1 Predict the Output: #include iostream void square(int); class functionCall { int number; public: functionCall(); }; functionCall::functionCall() { number=10;square(number); } ©NIIT OOPS/Lesson 7/Slide 15 of 25
16.
Constructors and Destructors Problem
Statement 5.P.1 (Contd.) void square(int num) { coutnumendl; num *= num; //This Expression Is //Resolved As num = num * num cout num endl; } int main() { functionCall f1; return 0; } ©NIIT OOPS/Lesson 7/Slide 16 of 25
17.
Constructors and Destructors Call
by Reference Is implemented by using An alias Pointers ©NIIT OOPS/Lesson 7/Slide 17 of 25
18.
Constructors and Destructors Call
by Reference (Contd.) Using an alias The same variable can be referenced by more than one name by using the or the alias operator The change in the value of the variable by the called or the calling program is reflected in all the affected functions ©NIIT OOPS/Lesson 7/Slide 18 of 25
19.
Constructors and Destructors Problem
Statement 5.P.2 Predict the Output: #include iostream void square(int ); class functionCall { int number; public: functionCall(); }; functionCall::functionCall() { number=10;square(number); } ©NIIT OOPS/Lesson 7/Slide 19 of 25
20.
Constructors and Destructors Problem
Statement 5.P.2 (Contd.) void square(int num) { coutnumendl; num *= num; //This Expression Is //Resolved As num = num * num cout num endl; } int main() { functionCall f1; return 0; } ©NIIT OOPS/Lesson 7/Slide 20 of 25
21.
Constructors and Destructors Call
by Reference using Pointers To define and declare a pointer variable: Using pointers Involves a pointer variable storing the memory address of any variable Is advantageous since it allows direct access to individual bytes in the memory and output devices Example: char var = 'G'; char *ptr ; //Pointer Declaration ptr = var; //Stores the address of //the variable ©NIIT OOPS/Lesson 7/Slide 21 of 25
22.
Constructors and Destructors Call
by Reference using Pointers (Contd.) Using pointers Allows dynamic allocation and release of memory that is program can obtain memory while it is running by using new and release by using delete operator Syntax: variable = new type; The type of variable mentioned on the left hand and the type mentioned on the right side of the new operator should match delete variable ©NIIT OOPS/Lesson 7/Slide 22 of 25
23.
Constructors and Destructors Summary In
this lesson, you learned that: Constructors are member functions of any class and are invoked the moment an instance of the class to which they belong is created A constructor function has the same name as its class A destructor function is invoked when any instance of a class ceases to exist A destructor function has the same name as its class but prefixed with a ~ (tilde) The member functions and the constructors of a class can also be defined outside the boundary of the class, using the scope resolution operator (::) ©NIIT OOPS/Lesson 7/Slide 23 of 25
24.
Constructors and Destructors Summary
(Contd.) The data that the function must receive when called from another function is/are called the parameters of a function In C++ programs, functions that have parameters are invoked in one of the following ways: A call by value A call by reference You can give two names to a variable by using the alias operator A reference provides an alias, or an alternate name for the variable ©NIIT OOPS/Lesson 7/Slide 24 of 25
25.
Constructors and Destructors Summary
(Contd.) A pointer is a variable that stores the memory address of another variable Dynamic allocation is the means by which a program can obtain memory while it is running The capability of obtaining memory as the need arises is provided by the new operator The delete operator is used to release memory ©NIIT OOPS/Lesson 7/Slide 25 of 25