SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
1
Getting Started with
C++
Trenton Computer Festival
March 15, 2014
Michael P. Redlich
@mpredli
about.me/mpredli/
Sunday, March 16, 14
Who’s Mike?
• BS in CS from
• “Petrochemical Research Organization”
• Ai-Logix, Inc. (now AudioCodes)
• Amateur Computer Group of New Jersey
• Publications
• Presentations
2
Sunday, March 16, 14
Objectives (1)
• What is C++?
• Evolution of C++
• Features of C++
• Review of Object-Oriented Programming
(OOP)
3
Sunday, March 16, 14
Objectives (2)
• Getting Started with C++
• introduction to the C++ class mechanism
• how to implement C++ classes
• Live Demos (yea!)
• C++ Resources
4
Sunday, March 16, 14
What is C++?
• “...a general purpose programming language
with a bias towards systems programming that
• is a better C,
• supports data abstraction,
• supports object-oriented programming,
• supports generic programming.”
Bjarne Stroustrup Web Site, http://www.stroustrup.com/C++.html
5
Sunday, March 16, 14
Evolution of C++ (1)
• Created by Bjarne Stroustrup
• AT&T Labs
• 1980 - originally named “C with
Classes”
• 1983 - redesigned and renamed to C++
• 1985 - available to the public
6
Sunday, March 16, 14
Evolution of C++ (2)
• 1989 - further extensions added
• templates and exception handling
• 1998 - C++ standardized
7
Sunday, March 16, 14
Features of C++
• Object-Oriented
Programming (OOP)
Language
• Pass-by-Reference
• Operator Overloading
• Generic Programming
• Exception Handling
• Namespaces
• Default Arguments
8
Sunday, March 16, 14
OOP Review (1)
• Programming Paradigm
• Four (4) Main Attributes
• data encapsulation
• data abstraction
• inheritance
• polymorphism
9
Sunday, March 16, 14
OOP Review (2)
• Abstract Data Type (ADT)
• user-defined data type
• use of objects through functions (methods)
without knowing the internal representation
10
Sunday, March 16, 14
OOP Review (3)
• Interface
• functions (methods) provided in the ADT that
allow access to data
• Implementation
• underlying data structure(s) and business logic
within the ADT
11
Sunday, March 16, 14
OOP Review (4)
• Class
• Defines a model
• Declares attributes
• Declares behavior
• Is an ADT
• Object
• Is an instance of a class
• Has state
• Has behavior
• May have many unique
objects of the same class
12
Sunday, March 16, 14
Advantages of OOP
• Interface can (and should) remain
unchanged when improving implementation
• Encourages modularity in application
development
• Better maintainability of code
• Code reuse
• Emphasis on what, not how
13
Sunday, March 16, 14
Some C++ Keywords
• class
• new, delete
• private,
protected, public
• try, throw, catch
• friend
• explicit
• virtual
• bool
• inline
14
Sunday, March 16, 14
Classes (1)
• A user-defined abstract data type
• Extension of C structs
• Contain:
• constructor
• destructor
• data members and member functions (methods)
15
Sunday, March 16, 14
Classes (2)
• Static/Dynamic object instantiation
• Multiple Constructors:
• Sports(void);
• Sports(char *,int,int);
• Sports(float,char *,int);
16
Sunday, March 16, 14
Classes (3)
• Class scope:
• scope resolution operator(::)
• Abstract Classes
• contain at least one pure virtual member
function (C++)
• contain at least one abstract method (Java)
17
Sunday, March 16, 14
Abstract Classes
• Pure virtual member function (C++)
• virtual void draw() = 0;
• Abstract method (Java)
• public abstract void draw();
18
Sunday, March 16, 14
Class Inheritance
19
Sunday, March 16, 14
20
// Sports class (partial listing)
class Sports {
private:
char *team;
int win;
public:
Sports(void);
Sports(char const *,int,int);
~Sports(void); // destructor
int getWin() const;
};
Sports::Sports(void) {
// define default constructor here...
}
Sports::Sports(const char *team,int win,int loss) {
// define primary constructor here...
}
int Sports::getWin() const {
return win;
}
Sunday, March 16, 14
21
// Baseball class (partial listing)
class Baseball : public Sports {
public:
Baseball(void);
Baseball(char const *,int,int);
~Baseball(void);
};
Baseball::Baseball(void) : Sports() {
}
Baseball::Baseball(const char *team,int win,int loss) :
Sports(team,win,loss) {
}
inline Baseball::~Baseball(void) {
}
Sunday, March 16, 14
Static Instantiation
• Object creation:
• Baseball mets(“Mets”,97,65);
• Access to public member functions:
• mets.getWin(); // returns 97
22
Sunday, March 16, 14
Dynamic Instantiation
• Object creation:
• Baseball *mets = new
Baseball(“Mets”,97,65);
• Access to public member functions:
• mets->getWin(); // returns 97
23
Sunday, March 16, 14
Deleting Objects
Baseball mets(“Mets”,97,65);
// object deleted when out of scope
Baseball *mets = new
Baseball(“Mets”,97,65);
delete mets; // required call
24
Sunday, March 16, 14
Operator new (1)
• Allocates memory on the free store (heap)
• Memory size is calculated by the compiler
• No more casting
• Automatic call to the constructor
• Used for built-in and user-defined data
types
25
Sunday, March 16, 14
Operator new (2)
int *var = new int; // int();
Sports *sports = new Sports();
// initializes an array of pointers
to type int
int *var = new int[10]
26
Sunday, March 16, 14
Operator delete (1)
• Deallocates memory on the free store
(heap)
• Automatic call to the destructor
• Must be used according to how operator
new was used
27
Sunday, March 16, 14
Operator delete (2)
int *var = new int;
delete var;
int *var = new int[10]
delete[] var;
28
Sunday, March 16, 14
Inline Member
Functions (1)
• Used for short functions (≤ 5 statements)
• Purpose:
• speed
• Good candidates for inline member
functions are those that access data
members
29
Sunday, March 16, 14
Inline Member
Functions (2)
• Explicit Use:
• use keyword inline in the definition of
member function
• Implicit Use:
• define the member function within its
declaration without using the keyword inline
30
Sunday, March 16, 14
Live Demo!
31
Sunday, March 16, 14
Popular C++
Compilers
32
• Embarcadero C++ Builder XE5
• embarcadero.com/products/
cbuilder
• MicrosoftVisual C++
• microsoft.com
• Open Watcom 1.9
• openwatcom.org
Sunday, March 16, 14
Local C++ User
Groups
• ACGNJ C++ Users Group
• facilitated by Bruce Arnold
• acgnj.barnold.us
33
Sunday, March 16, 14
Further Reading (1)
34
• C & C++ Code Capsules
• Chuck Allison
• freshsources.com
• The C++ Programming Language
• Bjarne Stroustrup
• stroustrup.com/4th.html
Sunday, March 16, 14
Further Reading (2)
35
• The Annotated C++ Reference Manual
• Margaret Ellis and Bjarne Stroustrup
• stroustrup.com/arm.html
• 1997 C++ Public Review Document
• C++ ISO JTC1/SC22/WG21 Committee
• open-std.org/jtc1/sc22/open/
n2356
Sunday, March 16, 14
Upcoming Events (1)
• Trenton Computer Festival
• March 14-15, 2014
• tcf-nj.org
• Emerging Technologies for the Enterprise
• April 22-23, 2014
• phillyemergingtech.com
36
Sunday, March 16, 14
37
Upcoming Events (2)
Sunday, March 16, 14
38
Thanks!
mike@redlich.net
@mpredli
javasig.org
Sunday, March 16, 14

Más contenido relacionado

Destacado

Literacy Assessment and the importance
Literacy Assessment and the importanceLiteracy Assessment and the importance
Literacy Assessment and the importancemforrester
 
Reducing traffic congestion
Reducing traffic congestionReducing traffic congestion
Reducing traffic congestionPrateek Mehta
 
Diapositivas de informatica
Diapositivas de informaticaDiapositivas de informatica
Diapositivas de informaticapaulaa06
 
Walk to school
Walk to schoolWalk to school
Walk to schoolmforrester
 
Design Portfolio - Link Version
Design Portfolio - Link VersionDesign Portfolio - Link Version
Design Portfolio - Link VersionNathan Jones
 
Rethink lockers
Rethink lockersRethink lockers
Rethink lockerssalnowak
 
Economic Analysis of a Jatropha Biodiesel-fired Power Plant in Nigeria
Economic Analysis of a Jatropha Biodiesel-fired Power Plant in NigeriaEconomic Analysis of a Jatropha Biodiesel-fired Power Plant in Nigeria
Economic Analysis of a Jatropha Biodiesel-fired Power Plant in NigeriaTosin Onabanjo
 
Presentation
PresentationPresentation
PresentationSher Sher
 
Slideshow test
Slideshow testSlideshow test
Slideshow testlorealcsr
 
Photo project in class samples
Photo project in class samplesPhoto project in class samples
Photo project in class samplesafpoff
 
NZCETA. Preparing for a New Entrepreneurial Economy
NZCETA.  Preparing for a New Entrepreneurial EconomyNZCETA.  Preparing for a New Entrepreneurial Economy
NZCETA. Preparing for a New Entrepreneurial EconomySteve Silvey
 
Review of Related Literature
Review of Related LiteratureReview of Related Literature
Review of Related LiteratureuLtralordjunior
 
Svetska banka e.e.zgrada
Svetska banka e.e.zgradaSvetska banka e.e.zgrada
Svetska banka e.e.zgradaSrpskiCEE
 
Two choices in life
Two choices in lifeTwo choices in life
Two choices in lifeWai Yip Chan
 
Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...
Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...
Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...Tosin Onabanjo
 
Dasrareports tribal-education
Dasrareports tribal-educationDasrareports tribal-education
Dasrareports tribal-educationSibbis
 

Destacado (20)

Literacy Assessment and the importance
Literacy Assessment and the importanceLiteracy Assessment and the importance
Literacy Assessment and the importance
 
Myself
MyselfMyself
Myself
 
Reducing traffic congestion
Reducing traffic congestionReducing traffic congestion
Reducing traffic congestion
 
Diapositivas de informatica
Diapositivas de informaticaDiapositivas de informatica
Diapositivas de informatica
 
Walk to school
Walk to schoolWalk to school
Walk to school
 
Design Portfolio - Link Version
Design Portfolio - Link VersionDesign Portfolio - Link Version
Design Portfolio - Link Version
 
Rethink lockers
Rethink lockersRethink lockers
Rethink lockers
 
Economic Analysis of a Jatropha Biodiesel-fired Power Plant in Nigeria
Economic Analysis of a Jatropha Biodiesel-fired Power Plant in NigeriaEconomic Analysis of a Jatropha Biodiesel-fired Power Plant in Nigeria
Economic Analysis of a Jatropha Biodiesel-fired Power Plant in Nigeria
 
Presentation
PresentationPresentation
Presentation
 
Slideshow test
Slideshow testSlideshow test
Slideshow test
 
Photo project in class samples
Photo project in class samplesPhoto project in class samples
Photo project in class samples
 
NZCETA. Preparing for a New Entrepreneurial Economy
NZCETA.  Preparing for a New Entrepreneurial EconomyNZCETA.  Preparing for a New Entrepreneurial Economy
NZCETA. Preparing for a New Entrepreneurial Economy
 
Review of Related Literature
Review of Related LiteratureReview of Related Literature
Review of Related Literature
 
Svetska banka e.e.zgrada
Svetska banka e.e.zgradaSvetska banka e.e.zgrada
Svetska banka e.e.zgrada
 
Two choices in life
Two choices in lifeTwo choices in life
Two choices in life
 
Визитка гвардейского увк 3
Визитка гвардейского увк 3Визитка гвардейского увк 3
Визитка гвардейского увк 3
 
Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...
Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...
Life Cycle Assessment of the use of Jatropha Biodiesel for Power Generation i...
 
Dasrareports tribal-education
Dasrareports tribal-educationDasrareports tribal-education
Dasrareports tribal-education
 
Aves gilang
Aves gilangAves gilang
Aves gilang
 
Kontrasepsi
KontrasepsiKontrasepsi
Kontrasepsi
 

Similar a Getting Started C

Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++Michael Redlich
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++Michael Redlich
 
C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)Michael Redlich
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Michael Redlich
 
Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)Michael Redlich
 
Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Michael Redlich
 
Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)Michael Redlich
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript TestingRan Mizrahi
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDBMichael Redlich
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.pptDevliNeeraj
 
Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Michael Redlich
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++jehan1987
 
Getting Started with Java
Getting Started with JavaGetting Started with Java
Getting Started with JavaMichael Redlich
 

Similar a Getting Started C (20)

Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
 
Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)
 
Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
Getting Started with Java
Getting Started with JavaGetting Started with Java
Getting Started with Java
 

Más de Michael Redlich

Getting Started with GitHub
Getting Started with GitHubGetting Started with GitHub
Getting Started with GitHubMichael Redlich
 
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
Building Microservices with Micronaut:  A Full-Stack JVM-Based FrameworkBuilding Microservices with Micronaut:  A Full-Stack JVM-Based Framework
Building Microservices with Micronaut: A Full-Stack JVM-Based FrameworkMichael Redlich
 
Building Microservices with Helidon: Oracle's New Java Microservices Framework
Building Microservices with Helidon:  Oracle's New Java Microservices FrameworkBuilding Microservices with Helidon:  Oracle's New Java Microservices Framework
Building Microservices with Helidon: Oracle's New Java Microservices FrameworkMichael Redlich
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesMichael Redlich
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesMichael Redlich
 
Building Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQBuilding Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQMichael Redlich
 
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)Michael Redlich
 
Building Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and MeteorBuilding Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and MeteorMichael Redlich
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with MeteorMichael Redlich
 

Más de Michael Redlich (10)

Getting Started with GitHub
Getting Started with GitHubGetting Started with GitHub
Getting Started with GitHub
 
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
Building Microservices with Micronaut:  A Full-Stack JVM-Based FrameworkBuilding Microservices with Micronaut:  A Full-Stack JVM-Based Framework
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
 
Building Microservices with Helidon: Oracle's New Java Microservices Framework
Building Microservices with Helidon:  Oracle's New Java Microservices FrameworkBuilding Microservices with Helidon:  Oracle's New Java Microservices Framework
Building Microservices with Helidon: Oracle's New Java Microservices Framework
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design Principles
 
Java Advanced Features
Java Advanced FeaturesJava Advanced Features
Java Advanced Features
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design Principles
 
Building Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQBuilding Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQ
 
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
 
Building Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and MeteorBuilding Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and Meteor
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with Meteor
 

Último

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

Getting Started C

  • 1. 1 Getting Started with C++ Trenton Computer Festival March 15, 2014 Michael P. Redlich @mpredli about.me/mpredli/ Sunday, March 16, 14
  • 2. Who’s Mike? • BS in CS from • “Petrochemical Research Organization” • Ai-Logix, Inc. (now AudioCodes) • Amateur Computer Group of New Jersey • Publications • Presentations 2 Sunday, March 16, 14
  • 3. Objectives (1) • What is C++? • Evolution of C++ • Features of C++ • Review of Object-Oriented Programming (OOP) 3 Sunday, March 16, 14
  • 4. Objectives (2) • Getting Started with C++ • introduction to the C++ class mechanism • how to implement C++ classes • Live Demos (yea!) • C++ Resources 4 Sunday, March 16, 14
  • 5. What is C++? • “...a general purpose programming language with a bias towards systems programming that • is a better C, • supports data abstraction, • supports object-oriented programming, • supports generic programming.” Bjarne Stroustrup Web Site, http://www.stroustrup.com/C++.html 5 Sunday, March 16, 14
  • 6. Evolution of C++ (1) • Created by Bjarne Stroustrup • AT&T Labs • 1980 - originally named “C with Classes” • 1983 - redesigned and renamed to C++ • 1985 - available to the public 6 Sunday, March 16, 14
  • 7. Evolution of C++ (2) • 1989 - further extensions added • templates and exception handling • 1998 - C++ standardized 7 Sunday, March 16, 14
  • 8. Features of C++ • Object-Oriented Programming (OOP) Language • Pass-by-Reference • Operator Overloading • Generic Programming • Exception Handling • Namespaces • Default Arguments 8 Sunday, March 16, 14
  • 9. OOP Review (1) • Programming Paradigm • Four (4) Main Attributes • data encapsulation • data abstraction • inheritance • polymorphism 9 Sunday, March 16, 14
  • 10. OOP Review (2) • Abstract Data Type (ADT) • user-defined data type • use of objects through functions (methods) without knowing the internal representation 10 Sunday, March 16, 14
  • 11. OOP Review (3) • Interface • functions (methods) provided in the ADT that allow access to data • Implementation • underlying data structure(s) and business logic within the ADT 11 Sunday, March 16, 14
  • 12. OOP Review (4) • Class • Defines a model • Declares attributes • Declares behavior • Is an ADT • Object • Is an instance of a class • Has state • Has behavior • May have many unique objects of the same class 12 Sunday, March 16, 14
  • 13. Advantages of OOP • Interface can (and should) remain unchanged when improving implementation • Encourages modularity in application development • Better maintainability of code • Code reuse • Emphasis on what, not how 13 Sunday, March 16, 14
  • 14. Some C++ Keywords • class • new, delete • private, protected, public • try, throw, catch • friend • explicit • virtual • bool • inline 14 Sunday, March 16, 14
  • 15. Classes (1) • A user-defined abstract data type • Extension of C structs • Contain: • constructor • destructor • data members and member functions (methods) 15 Sunday, March 16, 14
  • 16. Classes (2) • Static/Dynamic object instantiation • Multiple Constructors: • Sports(void); • Sports(char *,int,int); • Sports(float,char *,int); 16 Sunday, March 16, 14
  • 17. Classes (3) • Class scope: • scope resolution operator(::) • Abstract Classes • contain at least one pure virtual member function (C++) • contain at least one abstract method (Java) 17 Sunday, March 16, 14
  • 18. Abstract Classes • Pure virtual member function (C++) • virtual void draw() = 0; • Abstract method (Java) • public abstract void draw(); 18 Sunday, March 16, 14
  • 20. 20 // Sports class (partial listing) class Sports { private: char *team; int win; public: Sports(void); Sports(char const *,int,int); ~Sports(void); // destructor int getWin() const; }; Sports::Sports(void) { // define default constructor here... } Sports::Sports(const char *team,int win,int loss) { // define primary constructor here... } int Sports::getWin() const { return win; } Sunday, March 16, 14
  • 21. 21 // Baseball class (partial listing) class Baseball : public Sports { public: Baseball(void); Baseball(char const *,int,int); ~Baseball(void); }; Baseball::Baseball(void) : Sports() { } Baseball::Baseball(const char *team,int win,int loss) : Sports(team,win,loss) { } inline Baseball::~Baseball(void) { } Sunday, March 16, 14
  • 22. Static Instantiation • Object creation: • Baseball mets(“Mets”,97,65); • Access to public member functions: • mets.getWin(); // returns 97 22 Sunday, March 16, 14
  • 23. Dynamic Instantiation • Object creation: • Baseball *mets = new Baseball(“Mets”,97,65); • Access to public member functions: • mets->getWin(); // returns 97 23 Sunday, March 16, 14
  • 24. Deleting Objects Baseball mets(“Mets”,97,65); // object deleted when out of scope Baseball *mets = new Baseball(“Mets”,97,65); delete mets; // required call 24 Sunday, March 16, 14
  • 25. Operator new (1) • Allocates memory on the free store (heap) • Memory size is calculated by the compiler • No more casting • Automatic call to the constructor • Used for built-in and user-defined data types 25 Sunday, March 16, 14
  • 26. Operator new (2) int *var = new int; // int(); Sports *sports = new Sports(); // initializes an array of pointers to type int int *var = new int[10] 26 Sunday, March 16, 14
  • 27. Operator delete (1) • Deallocates memory on the free store (heap) • Automatic call to the destructor • Must be used according to how operator new was used 27 Sunday, March 16, 14
  • 28. Operator delete (2) int *var = new int; delete var; int *var = new int[10] delete[] var; 28 Sunday, March 16, 14
  • 29. Inline Member Functions (1) • Used for short functions (≤ 5 statements) • Purpose: • speed • Good candidates for inline member functions are those that access data members 29 Sunday, March 16, 14
  • 30. Inline Member Functions (2) • Explicit Use: • use keyword inline in the definition of member function • Implicit Use: • define the member function within its declaration without using the keyword inline 30 Sunday, March 16, 14
  • 32. Popular C++ Compilers 32 • Embarcadero C++ Builder XE5 • embarcadero.com/products/ cbuilder • MicrosoftVisual C++ • microsoft.com • Open Watcom 1.9 • openwatcom.org Sunday, March 16, 14
  • 33. Local C++ User Groups • ACGNJ C++ Users Group • facilitated by Bruce Arnold • acgnj.barnold.us 33 Sunday, March 16, 14
  • 34. Further Reading (1) 34 • C & C++ Code Capsules • Chuck Allison • freshsources.com • The C++ Programming Language • Bjarne Stroustrup • stroustrup.com/4th.html Sunday, March 16, 14
  • 35. Further Reading (2) 35 • The Annotated C++ Reference Manual • Margaret Ellis and Bjarne Stroustrup • stroustrup.com/arm.html • 1997 C++ Public Review Document • C++ ISO JTC1/SC22/WG21 Committee • open-std.org/jtc1/sc22/open/ n2356 Sunday, March 16, 14
  • 36. Upcoming Events (1) • Trenton Computer Festival • March 14-15, 2014 • tcf-nj.org • Emerging Technologies for the Enterprise • April 22-23, 2014 • phillyemergingtech.com 36 Sunday, March 16, 14