SlideShare a Scribd company logo
1 of 2
Download to read offline
C++​ ​Tips​ ​for​ ​Java​ ​Programmers
Memory
● Never​ ​ever​ ​new​ ​anything
● Never​ ​explicitly​ ​delete​ ​anything
● Use​ ​the​ ​stack/scope​ ​to​ ​control​ ​your​ ​object​ ​lifetimes
● Use​ ​value​ ​objects​ ​for​ ​almost​ ​all​ ​of​ ​your​ ​ownership
● Only​ ​use​ ​unique_ptr<>​ ​when​ ​you​ ​have​ ​to​ ​transfer​ ​ownership
● Only​ ​use​ ​shared_ptr<>​ ​if​ ​you​ ​are​ ​really​ ​going​ ​to​ ​share​ ​(and​ ​do​ ​you​ ​really​ ​need​ ​to?
Really?)
● Try​ ​to​ ​use​ ​std::make_unique​ ​when​ ​constructing​ ​objects​ ​for​ ​the​ ​unique_ptr
● Try​ ​to​ ​use​ ​std::make_shared​ ​when​ ​constructing​ ​objects​ ​for​ ​the​ ​shared_ptr
● Never​ ​use​ ​char*​ ​-​ ​use​ ​std::string
● Never​ ​use​ ​array[]
● Prefer​ ​std::vector​ ​to​ ​most​ ​data​ ​structures​ ​(or​ ​std::array)
● Only​ ​use​ ​other​ ​data​ ​structures​ ​if​ ​you​ ​need​ ​them​ ​-​ ​and​ ​don’t​ ​make​ ​up​ ​your​ ​own,​ ​use
composition/adaptor​ ​pattern
Class​ ​design
● Prefer​ ​to​ ​define​ ​at​ ​most​ ​the​ ​constructor​ ​(rule-of-zero)​ ​for​ ​the​ ​majority​ ​of​ ​your​ ​classes​ ​:
design​ ​your​ ​classes​ ​so​ ​that​ ​the​ ​default​ ​predefined​ ​functions​ ​work​ ​well
● If​ ​you​ ​need​ ​any​ ​more​ ​than​ ​just​ ​the​ ​constructor​ ​then​ ​the​ ​class​ ​should​ ​be​ ​focused
exclusively​ ​on​ ​ownership
Parameters/Return​ ​value
● As​ ​a​ ​rule​ ​parameters​ ​are​ ​either​ ​references​ ​or​ ​values
● If​ ​a​ ​parameter​ ​could​ ​be​ ​null​ ​then​ ​pointer​ ​is​ ​acceptable​ ​(should​ ​be​ ​the​ ​exception)
● Pass​ ​everything​ ​non-trivial​ ​as​ ​a​ ​reference​ ​-​ ​const​ ​if​ ​you​ ​can
● Possibly​ ​pass​ ​trivial​ ​stuff​ ​by​ ​value​ ​especially​ ​if​ ​they​ ​might​ ​take​ ​a​ ​copy
● Prefer​ ​return​ ​by​ ​value
● Use​ ​const​ ​as​ ​much​ ​as​ ​possible
● As​ ​a​ ​rule​ ​pass​ ​smart​ ​pointers​ ​by​ ​reference​ ​-​ ​unless​ ​participating​ ​in​ ​the​ ​object​ ​lifetime​ ​or
ownership
● Don’t​ ​have​ ​default​ ​values​ ​for​ ​parameters​ ​in​ ​virtual​ ​functions
● Use​ ​std:pair​ ​or​ ​std:tuple​ ​to​ ​return​ ​multiple​ ​values
Functions
● Make​ ​all​ ​getters​ ​const
● Avoid​ ​having​ ​complex​ ​objects​ ​as​ ​static​ ​in​ ​a​ ​function
Inheritance
● Prefer​ ​pure​ ​virtual​ ​if​ ​you​ ​need​ ​to​ ​specify​ ​an​ ​interface
● Always​ ​use​ ​override​ ​for​ ​overridden​ ​functions​ ​(and​ ​drop​ ​virtual)
● Never​ ​call​ ​a​ ​virtual​ ​function​ ​in​ ​a​ ​Constructor​ ​or​ ​a​ ​Destructor
● Any​ ​class​ ​with​ ​a​ ​virtual​ ​function​ ​needs​ ​a​ ​virtual​ ​Destructor
Object​ ​construction
● Initialize​ ​all​ ​members,​ ​always!
● Try​ ​to​ ​initiate​ ​all​ ​the​ ​members​ ​you​ ​can​ ​in​ ​the​ ​header
● Only​ ​initialize​ ​the​ ​ones​ ​depending​ ​on​ ​constructor​ ​parameters​ ​in​ ​the​ ​constructor​ ​list.
● Initialize​ ​these​ ​in​ ​the​ ​order​ ​specified​ ​in​ ​the​ ​header
● Try​ ​to​ ​always​ ​have​ ​an​ ​empty​ ​body​ ​in​ ​the​ ​constructor,​ ​it​ ​shouldn't​ ​do​ ​anything​ ​interesting
Constructs
● Prefer​ ​range​ ​based​ ​for
● Use​ ​std​ ​algorithms​ ​when​ ​appropriate
● Never​ ​use​ ​goto
● Use​ ​nullptr​ ​for​ ​null
● Use​ ​namespaces​ ​to​ ​represent​ ​packages
General
● Heed​ ​your​ ​compiler​ ​warnings
● Don’t​ ​use​ ​macros
● Beware​ ​of​ ​integer​ ​overflow
● Ask​ ​for​ ​help

More Related Content

Similar to C++ Tips for Java Programmers (JavaZone 2017)

CodingStandardsDoc
CodingStandardsDocCodingStandardsDoc
CodingStandardsDoc
Amol Patole
 

Similar to C++ Tips for Java Programmers (JavaZone 2017) (20)

Puppetizing Your Organization
Puppetizing Your OrganizationPuppetizing Your Organization
Puppetizing Your Organization
 
C++ boot camp part 1/2
C++ boot camp part 1/2C++ boot camp part 1/2
C++ boot camp part 1/2
 
C++ Boot Camp Part 1
C++ Boot Camp Part 1C++ Boot Camp Part 1
C++ Boot Camp Part 1
 
CodingStandardsDoc
CodingStandardsDocCodingStandardsDoc
CodingStandardsDoc
 
Review of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iiiReview of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iii
 
Style & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design PatternsStyle & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design Patterns
 
Optionals by Matt Faluotico
Optionals by Matt FaluoticoOptionals by Matt Faluotico
Optionals by Matt Faluotico
 
(3) c sharp introduction_basics_part_ii
(3) c sharp introduction_basics_part_ii(3) c sharp introduction_basics_part_ii
(3) c sharp introduction_basics_part_ii
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratch
 
Language tour of dart
Language tour of dartLanguage tour of dart
Language tour of dart
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
 
PHP & Mysql Code optimization
PHP & Mysql Code optimizationPHP & Mysql Code optimization
PHP & Mysql Code optimization
 
Tips from angular js users anonymous
Tips from angular js users anonymousTips from angular js users anonymous
Tips from angular js users anonymous
 
Testing Spark and Scala
Testing Spark and ScalaTesting Spark and Scala
Testing Spark and Scala
 
Game Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesGame Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design Principles
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
Aem best practices
Aem best practicesAem best practices
Aem best practices
 
Effective c# part1
Effective c# part1Effective c# part1
Effective c# part1
 
Struct
StructStruct
Struct
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet System
 

More from Patricia Aas

More from Patricia Aas (20)

NDC TechTown 2023_ Return Oriented Programming an introduction.pdf
NDC TechTown 2023_ Return Oriented Programming an introduction.pdfNDC TechTown 2023_ Return Oriented Programming an introduction.pdf
NDC TechTown 2023_ Return Oriented Programming an introduction.pdf
 
Telling a story
Telling a storyTelling a story
Telling a story
 
Return Oriented Programming, an introduction
Return Oriented Programming, an introductionReturn Oriented Programming, an introduction
Return Oriented Programming, an introduction
 
I can't work like this (KDE Academy Keynote 2021)
I can't work like this (KDE Academy Keynote 2021)I can't work like this (KDE Academy Keynote 2021)
I can't work like this (KDE Academy Keynote 2021)
 
Dependency Management in C++ (NDC TechTown 2021)
Dependency Management in C++ (NDC TechTown 2021)Dependency Management in C++ (NDC TechTown 2021)
Dependency Management in C++ (NDC TechTown 2021)
 
Introduction to Memory Exploitation (Meeting C++ 2021)
Introduction to Memory Exploitation (Meeting C++ 2021)Introduction to Memory Exploitation (Meeting C++ 2021)
Introduction to Memory Exploitation (Meeting C++ 2021)
 
Classic Vulnerabilities (MUCplusplus2022).pdf
Classic Vulnerabilities (MUCplusplus2022).pdfClassic Vulnerabilities (MUCplusplus2022).pdf
Classic Vulnerabilities (MUCplusplus2022).pdf
 
Classic Vulnerabilities (ACCU Keynote 2022)
Classic Vulnerabilities (ACCU Keynote 2022)Classic Vulnerabilities (ACCU Keynote 2022)
Classic Vulnerabilities (ACCU Keynote 2022)
 
Introduction to Memory Exploitation (CppEurope 2021)
Introduction to Memory Exploitation (CppEurope 2021)Introduction to Memory Exploitation (CppEurope 2021)
Introduction to Memory Exploitation (CppEurope 2021)
 
Thoughts On Learning A New Programming Language
Thoughts On Learning A New Programming LanguageThoughts On Learning A New Programming Language
Thoughts On Learning A New Programming Language
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
 
DevSecOps for Developers, How To Start (ETC 2020)
DevSecOps for Developers, How To Start (ETC 2020)DevSecOps for Developers, How To Start (ETC 2020)
DevSecOps for Developers, How To Start (ETC 2020)
 
The Anatomy of an Exploit (NDC TechTown 2019)
The Anatomy of an Exploit (NDC TechTown 2019)The Anatomy of an Exploit (NDC TechTown 2019)
The Anatomy of an Exploit (NDC TechTown 2019)
 
Elections: Trust and Critical Infrastructure (NDC TechTown 2019)
Elections: Trust and Critical Infrastructure (NDC TechTown 2019)Elections: Trust and Critical Infrastructure (NDC TechTown 2019)
Elections: Trust and Critical Infrastructure (NDC TechTown 2019)
 
The Anatomy of an Exploit (NDC TechTown 2019))
The Anatomy of an Exploit (NDC TechTown 2019))The Anatomy of an Exploit (NDC TechTown 2019))
The Anatomy of an Exploit (NDC TechTown 2019))
 
Elections, Trust and Critical Infrastructure (NDC TechTown)
Elections, Trust and Critical Infrastructure (NDC TechTown)Elections, Trust and Critical Infrastructure (NDC TechTown)
Elections, Trust and Critical Infrastructure (NDC TechTown)
 
Survival Tips for Women in Tech (JavaZone 2019)
Survival Tips for Women in Tech (JavaZone 2019) Survival Tips for Women in Tech (JavaZone 2019)
Survival Tips for Women in Tech (JavaZone 2019)
 
Embedded Ethics (EuroBSDcon 2019)
Embedded Ethics (EuroBSDcon 2019)Embedded Ethics (EuroBSDcon 2019)
Embedded Ethics (EuroBSDcon 2019)
 
Chromium Sandbox on Linux (NDC Security 2019)
Chromium Sandbox on Linux (NDC Security 2019)Chromium Sandbox on Linux (NDC Security 2019)
Chromium Sandbox on Linux (NDC Security 2019)
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Recently uploaded (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

C++ Tips for Java Programmers (JavaZone 2017)

  • 1. C++​ ​Tips​ ​for​ ​Java​ ​Programmers Memory ● Never​ ​ever​ ​new​ ​anything ● Never​ ​explicitly​ ​delete​ ​anything ● Use​ ​the​ ​stack/scope​ ​to​ ​control​ ​your​ ​object​ ​lifetimes ● Use​ ​value​ ​objects​ ​for​ ​almost​ ​all​ ​of​ ​your​ ​ownership ● Only​ ​use​ ​unique_ptr<>​ ​when​ ​you​ ​have​ ​to​ ​transfer​ ​ownership ● Only​ ​use​ ​shared_ptr<>​ ​if​ ​you​ ​are​ ​really​ ​going​ ​to​ ​share​ ​(and​ ​do​ ​you​ ​really​ ​need​ ​to? Really?) ● Try​ ​to​ ​use​ ​std::make_unique​ ​when​ ​constructing​ ​objects​ ​for​ ​the​ ​unique_ptr ● Try​ ​to​ ​use​ ​std::make_shared​ ​when​ ​constructing​ ​objects​ ​for​ ​the​ ​shared_ptr ● Never​ ​use​ ​char*​ ​-​ ​use​ ​std::string ● Never​ ​use​ ​array[] ● Prefer​ ​std::vector​ ​to​ ​most​ ​data​ ​structures​ ​(or​ ​std::array) ● Only​ ​use​ ​other​ ​data​ ​structures​ ​if​ ​you​ ​need​ ​them​ ​-​ ​and​ ​don’t​ ​make​ ​up​ ​your​ ​own,​ ​use composition/adaptor​ ​pattern Class​ ​design ● Prefer​ ​to​ ​define​ ​at​ ​most​ ​the​ ​constructor​ ​(rule-of-zero)​ ​for​ ​the​ ​majority​ ​of​ ​your​ ​classes​ ​: design​ ​your​ ​classes​ ​so​ ​that​ ​the​ ​default​ ​predefined​ ​functions​ ​work​ ​well ● If​ ​you​ ​need​ ​any​ ​more​ ​than​ ​just​ ​the​ ​constructor​ ​then​ ​the​ ​class​ ​should​ ​be​ ​focused exclusively​ ​on​ ​ownership Parameters/Return​ ​value ● As​ ​a​ ​rule​ ​parameters​ ​are​ ​either​ ​references​ ​or​ ​values ● If​ ​a​ ​parameter​ ​could​ ​be​ ​null​ ​then​ ​pointer​ ​is​ ​acceptable​ ​(should​ ​be​ ​the​ ​exception) ● Pass​ ​everything​ ​non-trivial​ ​as​ ​a​ ​reference​ ​-​ ​const​ ​if​ ​you​ ​can ● Possibly​ ​pass​ ​trivial​ ​stuff​ ​by​ ​value​ ​especially​ ​if​ ​they​ ​might​ ​take​ ​a​ ​copy ● Prefer​ ​return​ ​by​ ​value ● Use​ ​const​ ​as​ ​much​ ​as​ ​possible ● As​ ​a​ ​rule​ ​pass​ ​smart​ ​pointers​ ​by​ ​reference​ ​-​ ​unless​ ​participating​ ​in​ ​the​ ​object​ ​lifetime​ ​or ownership ● Don’t​ ​have​ ​default​ ​values​ ​for​ ​parameters​ ​in​ ​virtual​ ​functions ● Use​ ​std:pair​ ​or​ ​std:tuple​ ​to​ ​return​ ​multiple​ ​values Functions ● Make​ ​all​ ​getters​ ​const ● Avoid​ ​having​ ​complex​ ​objects​ ​as​ ​static​ ​in​ ​a​ ​function
  • 2. Inheritance ● Prefer​ ​pure​ ​virtual​ ​if​ ​you​ ​need​ ​to​ ​specify​ ​an​ ​interface ● Always​ ​use​ ​override​ ​for​ ​overridden​ ​functions​ ​(and​ ​drop​ ​virtual) ● Never​ ​call​ ​a​ ​virtual​ ​function​ ​in​ ​a​ ​Constructor​ ​or​ ​a​ ​Destructor ● Any​ ​class​ ​with​ ​a​ ​virtual​ ​function​ ​needs​ ​a​ ​virtual​ ​Destructor Object​ ​construction ● Initialize​ ​all​ ​members,​ ​always! ● Try​ ​to​ ​initiate​ ​all​ ​the​ ​members​ ​you​ ​can​ ​in​ ​the​ ​header ● Only​ ​initialize​ ​the​ ​ones​ ​depending​ ​on​ ​constructor​ ​parameters​ ​in​ ​the​ ​constructor​ ​list. ● Initialize​ ​these​ ​in​ ​the​ ​order​ ​specified​ ​in​ ​the​ ​header ● Try​ ​to​ ​always​ ​have​ ​an​ ​empty​ ​body​ ​in​ ​the​ ​constructor,​ ​it​ ​shouldn't​ ​do​ ​anything​ ​interesting Constructs ● Prefer​ ​range​ ​based​ ​for ● Use​ ​std​ ​algorithms​ ​when​ ​appropriate ● Never​ ​use​ ​goto ● Use​ ​nullptr​ ​for​ ​null ● Use​ ​namespaces​ ​to​ ​represent​ ​packages General ● Heed​ ​your​ ​compiler​ ​warnings ● Don’t​ ​use​ ​macros ● Beware​ ​of​ ​integer​ ​overflow ● Ask​ ​for​ ​help