SlideShare una empresa de Scribd logo
1 de 58
The C++ Language
The C++ Language ,[object Object],C++ was designed to provide Simula’s facilities for program organization together with C’s efficiency and flexibility for systems programming.
C++ Features ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: A stack in C typedef struct { char s[SIZE]; int  sp; } Stack; stack *create() { Stack *s; s = (Stack *)malloc(sizeof(Stack)); s->sp = 0; return s; } Creator function ensures stack is created properly. Does not help for stack that is automatic variable. Programmer could inadvertently create uninitialized stack.                                                                                                               
Example: A stack in C char pop(Stack *s) { if (sp = 0) error(“Underflow”); return s->s[--sp]; } void push(Stack *s, char v) { if (sp == SIZE) error(“Overflow”); s->s[sp++] = v; } Not clear these are the only stack-related functions. Another part of program can modify any stack any way it wants to, destroying invariants. Temptation to inline these computations, not use functions.
C++ Solution: Class class Stack { char s[SIZE]; int sp; public: Stack() { sp = 0; } void push(char v) { if (sp == SIZE) error(“overflow”); s[sp++] = v; } char pop() { if (sp == 0) error(“underflow”); return s[--sp]; } }; Definition of both representation and operations Constructor: initializes Public: visible outside the class Member functions see object fields like local variables
C++ Stack Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C++ Stack Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Implementation ,[object Object],C++ class Stack { char s[SIZE]; int sp; public: Stack() void push(char); char pop(); }; Equivalent C implementation struct Stack { char s[SIZE]; int sp; }; void st_Stack(Stack*); void st_push(Stack*, char); char st_pop(Stack*);
Operator Overloading ,[object Object],[object Object],[object Object],[object Object],Creating objects of the user-defined type Want + to mean something different in this context Promote 2.3 to a complex number here
Example: Complex number type ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Pass-by-reference reduces copying  Operator overloading defines arithmetic operators for the complex type
References ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Complex Number Type ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Complex Number Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Function Overloading ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Const ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Templates ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Template Stack Class template <class T> class Stack { T s[SIZE]; int sp; public: Stack() { sp = 0; } void push(T v) { if (sp == SIZE) error(“overflow”); s[sp++] = v; } T pop() { if (sp == 0) error(“underflow”); return s[--sp]; } }; T is a type argument Used like a type within the body
Using a template Stack<char> cs; // Instantiates the specialized code cs.push(‘a’); char c = cs.pop(); Stack<double *> dps; double d; dps.push(&d);
Display-list example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object]
Inheritance class Shape { double x, y; // Base coordinates of shape public: void translate(double dx, double dy) { x += dx; y += dy; } }; class Line : public Shape { }; Line l; l.translate(1,3); // Invoke Shape::translate() Line inherits both the representation and member functions of the Shape class
Implementing Inheritance ,[object Object],[object Object],C++ class Shape { double x, y; }; class Box : Shape { double h, w; }; Equivalent C implementation struct Shape { double x, y }; struct Box { double x, y; double h, w; };
Virtual Functions class Shape { virtual void draw(); }; class Line : public Shape { void draw(); }; class Arc : public Shape { void draw(); }; Shape *dl[10]; dl[0] = new Line; dl[1] = new Arc; dl[0]->draw(); // invoke Line::draw() dl[1]->draw(); // invoke Arc::draw() draw() is a virtual function invoked based on the actual type of the object, not the type of the pointer New classes can be added without having to change “draw everything” code
Implementing Virtual Functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],a b vptr &Virt::foo &Virt::bar Object of type Virt Virtual table for class Virt C++   void f(Virt *v) { v->bar(); } Equivalent C implementation  void f(Virt *v) { (*(v->vptr.bar))(v); }
Cfront ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Default arguments ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Declarations may appear anywhere ,[object Object],void f(int i, const char *p) { if (i<=0) error(); const int len = strlen(p); char c = 0; for (int j = i ; j<len ; j++) c += p[j]; }
Multiple Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object]
Multiple Inheritance Ambiguities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multiple Inheritance Ambiguities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Duplicate Base Classes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Duplicate Base Classes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing Multiple Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],B A C B *b C *c or A *a In-memory representation of a C
Implementation Using VT Offsets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],x y vptr &C::f 0 &C::f –2 c C’s vtbl vptr z &B::g 0 B in C’s vtbl b
Implementation Using Thunks ,[object Object],[object Object],x y vptr &C::f &C::f_in_B c C’s vtbl vptr z &B::g B in C’s vtbl b void C::f_in_B(void* this) { return C::f(this – 2); }
Namespaces ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],                                                                                                                                   
Namespaces ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Namespaces ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Namespaces ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Namespaces ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exceptions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Standard Template Library ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C++ IO Facilities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C++ IO Facilities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C++ string class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C++ STL Containers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Iterators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],… v.begin() v.end()
Other Containers Insert/Delete from front mid. end random access vector O(n) O(n) O(1) O(1) list O(1) O(1) O(1) O(n) deque O(1) O(n) O(1) O(n)
Associative Containers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C++ in Embedded Systems ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C++ Features With No Impact ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Inexpensive C++ Features ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Medium-cost Features ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
High-cost Features ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
High-cost Features ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
High-cost Features ,[object Object],[object Object],[object Object],[object Object]
Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
C++ theory
C++ theoryC++ theory
C++ theory
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
C++ book
C++ bookC++ book
C++ book
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
 
20 C programs
20 C programs20 C programs
20 C programs
 
What is c
What is cWhat is c
What is c
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
C Basics
C BasicsC Basics
C Basics
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language
 
Oops lecture 1
Oops lecture 1Oops lecture 1
Oops lecture 1
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6
 
C++11
C++11C++11
C++11
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 

Destacado

C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language CourseVivek chan
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS ConceptBoopathi K
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)Ritika Sharma
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic conceptsAbhinav Vatsa
 
Overview of c language
Overview of c languageOverview of c language
Overview of c languageshalini392
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language Mohamed Loey
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
Stamford International University IT Orientation 3/2016
Stamford International University IT Orientation 3/2016Stamford International University IT Orientation 3/2016
Stamford International University IT Orientation 3/2016Mintra Ruensuk
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programmingavikdhupar
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)Dushmanta Nath
 

Destacado (20)

C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Data types
Data typesData types
Data types
 
OOP
OOPOOP
OOP
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 
Function in c
Function in cFunction in c
Function in c
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
Function in C program
Function in C programFunction in C program
Function in C program
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Array in c language
Array in c languageArray in c language
Array in c language
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Stamford International University IT Orientation 3/2016
Stamford International University IT Orientation 3/2016Stamford International University IT Orientation 3/2016
Stamford International University IT Orientation 3/2016
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
C language ppt
C language pptC language ppt
C language ppt
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)
 

Similar a C++ Language

c++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdfc++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdfnisarmca
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classDeepak Singh
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)Chhom Karath
 
麻省理工C++公开教学课程(二)
麻省理工C++公开教学课程(二)麻省理工C++公开教学课程(二)
麻省理工C++公开教学课程(二)ProCharm
 
Functions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupFunctions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupSyedHaroonShah4
 
from java to c
from java to cfrom java to c
from java to cVõ Hòa
 
Review constdestr
Review constdestrReview constdestr
Review constdestrrajudasraju
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfmohdjakirfb
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of cTushar B Kute
 
OO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionOO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionYu-Sheng (Yosen) Chen
 

Similar a C++ Language (20)

Basics of objective c
Basics of objective cBasics of objective c
Basics of objective c
 
c++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdfc++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdf
 
C++ programs
C++ programsC++ programs
C++ programs
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
Lecture4
Lecture4Lecture4
Lecture4
 
Lecture4
Lecture4Lecture4
Lecture4
 
麻省理工C++公开教学课程(二)
麻省理工C++公开教学课程(二)麻省理工C++公开教学课程(二)
麻省理工C++公开教学课程(二)
 
Functions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupFunctions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrup
 
from java to c
from java to cfrom java to c
from java to c
 
Review constdestr
Review constdestrReview constdestr
Review constdestr
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
 
Tu1
Tu1Tu1
Tu1
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
OO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionOO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual Function
 

Más de Vidyacenter

Más de Vidyacenter (6)

Example Projectile Motion
Example Projectile MotionExample Projectile Motion
Example Projectile Motion
 
Clanguage
ClanguageClanguage
Clanguage
 
Advance Java
Advance JavaAdvance Java
Advance Java
 
Interview Tips
Interview TipsInterview Tips
Interview Tips
 
Gre Ppt
Gre PptGre Ppt
Gre Ppt
 
Gmat Ppt
Gmat PptGmat Ppt
Gmat Ppt
 

Último

Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith PereraKenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Pereraictsugar
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Seta Wicaksana
 
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...lizamodels9
 
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City GurgaonCall Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaoncallgirls2057
 
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In.../:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...lizamodels9
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menzaictsugar
 
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCRashishs7044
 
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdfNewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdfKhaled Al Awadi
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...lizamodels9
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...ictsugar
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03DallasHaselhorst
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfrichard876048
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyotictsugar
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailAriel592675
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCRashishs7044
 
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024christinemoorman
 
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort ServiceCall US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Servicecallgirls2057
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy Verified Accounts
 

Último (20)

Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith PereraKenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Perera
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...
 
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
 
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City GurgaonCall Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
 
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In.../:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
 
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
 
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdfNewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdf
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detail
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
 
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024
 
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort ServiceCall US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail Accounts
 

C++ Language

  • 2.
  • 3.
  • 4. Example: A stack in C typedef struct { char s[SIZE]; int sp; } Stack; stack *create() { Stack *s; s = (Stack *)malloc(sizeof(Stack)); s->sp = 0; return s; } Creator function ensures stack is created properly. Does not help for stack that is automatic variable. Programmer could inadvertently create uninitialized stack.                                                                                                              
  • 5. Example: A stack in C char pop(Stack *s) { if (sp = 0) error(“Underflow”); return s->s[--sp]; } void push(Stack *s, char v) { if (sp == SIZE) error(“Overflow”); s->s[sp++] = v; } Not clear these are the only stack-related functions. Another part of program can modify any stack any way it wants to, destroying invariants. Temptation to inline these computations, not use functions.
  • 6. C++ Solution: Class class Stack { char s[SIZE]; int sp; public: Stack() { sp = 0; } void push(char v) { if (sp == SIZE) error(“overflow”); s[sp++] = v; } char pop() { if (sp == 0) error(“underflow”); return s[--sp]; } }; Definition of both representation and operations Constructor: initializes Public: visible outside the class Member functions see object fields like local variables
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18. Template Stack Class template <class T> class Stack { T s[SIZE]; int sp; public: Stack() { sp = 0; } void push(T v) { if (sp == SIZE) error(“overflow”); s[sp++] = v; } T pop() { if (sp == 0) error(“underflow”); return s[--sp]; } }; T is a type argument Used like a type within the body
  • 19. Using a template Stack<char> cs; // Instantiates the specialized code cs.push(‘a’); char c = cs.pop(); Stack<double *> dps; double d; dps.push(&d);
  • 20.
  • 21.
  • 22. Inheritance class Shape { double x, y; // Base coordinates of shape public: void translate(double dx, double dy) { x += dx; y += dy; } }; class Line : public Shape { }; Line l; l.translate(1,3); // Invoke Shape::translate() Line inherits both the representation and member functions of the Shape class
  • 23.
  • 24. Virtual Functions class Shape { virtual void draw(); }; class Line : public Shape { void draw(); }; class Arc : public Shape { void draw(); }; Shape *dl[10]; dl[0] = new Line; dl[1] = new Arc; dl[0]->draw(); // invoke Line::draw() dl[1]->draw(); // invoke Arc::draw() draw() is a virtual function invoked based on the actual type of the object, not the type of the pointer New classes can be added without having to change “draw everything” code
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49. Other Containers Insert/Delete from front mid. end random access vector O(n) O(n) O(1) O(1) list O(1) O(1) O(1) O(n) deque O(1) O(n) O(1) O(n)
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.