SlideShare a Scribd company logo
1
Getting Started with
C++
Trenton Computer Festival
March 17, 2018
Michael P. Redlich
@mpredli
about.me/mpredli/
Who’s Mike?
• BS in CS from
• “Petrochemical Research Organization”
• Java Queue News Editor, InfoQ
• Ai-Logix, Inc. (now AudioCodes)
• Amateur Computer Group of New Jersey
2
Objectives (1)
• What is C++?
• Evolution of C++
• Features of C++
• Review of Object-Oriented Programming
(OOP)
3
Objectives (2)
• Getting Started with C++
• introduction to the C++ class mechanism
• how to implement C++ classes
• Live Demos (yea!)
• C++ Resources
4
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
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
Evolution of C++ (2)
• 1989 - further extensions added
• templates and exception handling
• 1998 - C++ standardized
7
Features of C++
• Object-Oriented
Programming (OOP)
Language
• Pass-by-Reference
• Operator Overloading
• Generic Programming
• Exception Handling
• Namespaces
• Default Arguments
8
OOP Review (1)
• Programming Paradigm
• Four (4) Main Attributes
• data encapsulation
• data abstraction
• inheritance
• polymorphism
9
OOP Review (2)
• Abstract Data Type (ADT)
• user-defined data type
• use of objects through functions (methods)
without knowing the internal representation
10
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
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
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
Some C++ Keywords
• class
• new, delete
• private,
protected, public
• try, throw, catch
• friend
• explicit
• virtual
• bool
• inline
14
Classes (1)
• A user-defined abstract data type
• Extension of C structs
• Contain:
• constructor
• destructor
• data members and member functions (methods)
15
Classes (2)
• Static/Dynamic object instantiation
• Multiple Constructors:
• Sports(void);
• Sports(char *,int,int);
• Sports(float,char *,int);
16
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
Abstract Classes
• Pure virtual member function (C++)
• virtual void draw() = 0;
• Abstract method (Java)
• public abstract void draw();
18
Class Inheritance
19
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;
}
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) {
}
Static Instantiation
• Object creation:
• Baseball mets(“Mets”,97,65);
• Access to public member functions:
• mets.getWin(); // returns 97
22
Dynamic Instantiation
• Object creation:
• Baseball *mets = new
Baseball(“Mets”,97,65);
• Access to public member functions:
• mets->getWin(); // returns 97
23
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
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
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
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
Operator delete (2)
int *var = new int;
delete var;
int *var = new int[10]
delete[] var;
28
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
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
Live Demo!
31
Popular C++
Compilers
32
• Embarcadero C++ Builder XE7
• embarcadero.com/products/cbuilder
• MicrosoftVisual C++
• microsoft.com
• Intel System Studio
• software.intel.com/en-us/c-
compilers
Popular C++
Compilers
33
• Open Watcom 1.9 (June 2010)
• openwatcom.org
Local C++ User
Groups
• ACGNJ C++ Users Group
• facilitated by Bruce Arnold
• acgnj.barnold.us
34
Further Reading (1)
35
• C & C++ Code Capsules
• Chuck Allison
• freshsources.com
• The C++ Programming Language
• Bjarne Stroustrup
• stroustrup.com/4th.html
Further Reading (2)
36
• 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
Upcoming Events
• ACGNJ Java Users Group
• Dr. Venkat Subramaniam
• Monday, March 19, 2018
• DorothyYoung Center for the Arts, Room 106
• Drew University
• 7:30-9:00pm
• “Twelve Ways to Make Code Suck Less”
37
38
Thanks!
mike@redlich.net
@mpredli
redlich.net
slideshare.net/mpredli01
github.com/mpredli01
Upcoming Events
• March 17-18, 2017
•tcf-nj.org
• April 18-19, 2017
•phillyemergingtech.com
39

More Related Content

What's hot

Java Day-4
Java Day-4Java Day-4
Java Day-4
People Strategists
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
People Strategists
 
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
Iosif Itkin
 
Reducing Redundancies in Multi-Revision Code Analysis
Reducing Redundancies in Multi-Revision Code AnalysisReducing Redundancies in Multi-Revision Code Analysis
Reducing Redundancies in Multi-Revision Code Analysis
Sebastiano Panichella
 
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Integration with swift
Integration with swiftIntegration with swift
Integration with swift
ichiko_revjune
 
Roslyn
RoslynRoslyn

What's hot (9)

Java Day-4
Java Day-4Java Day-4
Java Day-4
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
 
Reducing Redundancies in Multi-Revision Code Analysis
Reducing Redundancies in Multi-Revision Code AnalysisReducing Redundancies in Multi-Revision Code Analysis
Reducing Redundancies in Multi-Revision Code Analysis
 
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
 
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
 
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
 
Integration with swift
Integration with swiftIntegration with swift
Integration with swift
 
Roslyn
RoslynRoslyn
Roslyn
 

Similar to Getting Started with C++

C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
Michael Redlich
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
Michael Redlich
 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
FarazKhan89093
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
MZGINBarwary
 
Getting Started with Java
Getting Started with JavaGetting Started with Java
Getting Started with Java
Michael Redlich
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
ssuser0c24d5
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
nilesh405711
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
YashpalYadav46
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
DevliNeeraj
 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
vinu28455
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
Siraj Memon
 
AOP on Android
AOP on AndroidAOP on Android
AOP on Android
Tibor Srámek
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++
Andrey Karpov
 
introduction to c #
introduction to c #introduction to c #
introduction to c #
Sireesh K
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
jehan1987
 
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)   A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
David Salz
 
B.sc CSIT 2nd semester C++ unit-1
B.sc CSIT  2nd semester C++ unit-1B.sc CSIT  2nd semester C++ unit-1
B.sc CSIT 2nd semester C++ unit-1
Tekendra Nath Yogi
 
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
Michael Redlich
 
David buksbaum a-briefintroductiontocsharp
David buksbaum a-briefintroductiontocsharpDavid buksbaum a-briefintroductiontocsharp
David buksbaum a-briefintroductiontocsharp
Jorge Antonio Contre Vargas
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
ActiveState
 

Similar to Getting Started with C++ (20)

C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
Getting Started with Java
Getting Started with JavaGetting Started with Java
Getting Started with Java
 
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
 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
 
AOP on Android
AOP on AndroidAOP on Android
AOP on Android
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++
 
introduction to c #
introduction to c #introduction to c #
introduction to c #
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)   A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
 
B.sc CSIT 2nd semester C++ unit-1
B.sc CSIT  2nd semester C++ unit-1B.sc CSIT  2nd semester C++ unit-1
B.sc CSIT 2nd semester C++ unit-1
 
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
 
David buksbaum a-briefintroductiontocsharp
David buksbaum a-briefintroductiontocsharpDavid buksbaum a-briefintroductiontocsharp
David buksbaum a-briefintroductiontocsharp
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 

More from Michael Redlich

Getting Started with GitHub
Getting Started with GitHubGetting Started with GitHub
Getting Started with GitHub
Michael 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 Framework
Michael 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 Framework
Michael Redlich
 
Java Advanced Features
Java Advanced FeaturesJava Advanced Features
Java Advanced Features
Michael 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 Principles
Michael 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 jOOQ
Michael 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 Meteor
Michael Redlich
 
Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Java Advanced Features (TCF 2014)
Java 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 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
 
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
 
C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (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 MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
Michael Redlich
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with Meteor
Michael Redlich
 

More from Michael Redlich (16)

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
 
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
 
Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Java Advanced Features (TCF 2014)
Java 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 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)
 
Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)
 
C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (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)
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with Meteor
 

Recently uploaded

Quarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabhQuarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
aisafed42
 
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLESINTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
anfaltahir1010
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
Envertis Software Solutions
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 

Recently uploaded (20)

Quarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabhQuarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
 
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLESINTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 

Getting Started with C++

  • 1. 1 Getting Started with C++ Trenton Computer Festival March 17, 2018 Michael P. Redlich @mpredli about.me/mpredli/
  • 2. Who’s Mike? • BS in CS from • “Petrochemical Research Organization” • Java Queue News Editor, InfoQ • Ai-Logix, Inc. (now AudioCodes) • Amateur Computer Group of New Jersey 2
  • 3. Objectives (1) • What is C++? • Evolution of C++ • Features of C++ • Review of Object-Oriented Programming (OOP) 3
  • 4. Objectives (2) • Getting Started with C++ • introduction to the C++ class mechanism • how to implement C++ classes • Live Demos (yea!) • C++ Resources 4
  • 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
  • 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
  • 7. Evolution of C++ (2) • 1989 - further extensions added • templates and exception handling • 1998 - C++ standardized 7
  • 8. Features of C++ • Object-Oriented Programming (OOP) Language • Pass-by-Reference • Operator Overloading • Generic Programming • Exception Handling • Namespaces • Default Arguments 8
  • 9. OOP Review (1) • Programming Paradigm • Four (4) Main Attributes • data encapsulation • data abstraction • inheritance • polymorphism 9
  • 10. OOP Review (2) • Abstract Data Type (ADT) • user-defined data type • use of objects through functions (methods) without knowing the internal representation 10
  • 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
  • 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
  • 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
  • 14. Some C++ Keywords • class • new, delete • private, protected, public • try, throw, catch • friend • explicit • virtual • bool • inline 14
  • 15. Classes (1) • A user-defined abstract data type • Extension of C structs • Contain: • constructor • destructor • data members and member functions (methods) 15
  • 16. Classes (2) • Static/Dynamic object instantiation • Multiple Constructors: • Sports(void); • Sports(char *,int,int); • Sports(float,char *,int); 16
  • 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
  • 18. Abstract Classes • Pure virtual member function (C++) • virtual void draw() = 0; • Abstract method (Java) • public abstract void draw(); 18
  • 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; }
  • 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) { }
  • 22. Static Instantiation • Object creation: • Baseball mets(“Mets”,97,65); • Access to public member functions: • mets.getWin(); // returns 97 22
  • 23. Dynamic Instantiation • Object creation: • Baseball *mets = new Baseball(“Mets”,97,65); • Access to public member functions: • mets->getWin(); // returns 97 23
  • 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
  • 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
  • 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
  • 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
  • 28. Operator delete (2) int *var = new int; delete var; int *var = new int[10] delete[] var; 28
  • 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
  • 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
  • 32. Popular C++ Compilers 32 • Embarcadero C++ Builder XE7 • embarcadero.com/products/cbuilder • MicrosoftVisual C++ • microsoft.com • Intel System Studio • software.intel.com/en-us/c- compilers
  • 33. Popular C++ Compilers 33 • Open Watcom 1.9 (June 2010) • openwatcom.org
  • 34. Local C++ User Groups • ACGNJ C++ Users Group • facilitated by Bruce Arnold • acgnj.barnold.us 34
  • 35. Further Reading (1) 35 • C & C++ Code Capsules • Chuck Allison • freshsources.com • The C++ Programming Language • Bjarne Stroustrup • stroustrup.com/4th.html
  • 36. Further Reading (2) 36 • 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
  • 37. Upcoming Events • ACGNJ Java Users Group • Dr. Venkat Subramaniam • Monday, March 19, 2018 • DorothyYoung Center for the Arts, Room 106 • Drew University • 7:30-9:00pm • “Twelve Ways to Make Code Suck Less” 37
  • 39. Upcoming Events • March 17-18, 2017 •tcf-nj.org • April 18-19, 2017 •phillyemergingtech.com 39