Kate Gregory Gregory Consulting James Mc Nellis Senior

  • Slides: 24
Download presentation
Kate Gregory | Gregory Consulting James Mc. Nellis | Senior Engineer, Visual C++

Kate Gregory | Gregory Consulting James Mc. Nellis | Senior Engineer, Visual C++

Meet Kate Gregory | @gregcons • Consultant (mentor), author, developer • All about community

Meet Kate Gregory | @gregcons • Consultant (mentor), author, developer • All about community – MVP, RD, user groups, conferences – Stack. Overflow – Twitter, blog, Facebook… • Over 35 years of industry experience • Using C++ since before Microsoft had a C++ compiler

Meet James Mc. Nellis | @James. Mc. Nellis • Senior Software Development Engineer at

Meet James Mc. Nellis | @James. Mc. Nellis • Senior Software Development Engineer at Microsoft – Currently a member of the Visual C++ Libraries team • One of the top C++ contributors on Stack. Overflow • Using C++ since Microsoft released Visual C++ 6. 0 • Usually has absolutely no idea what he is doing

Course Topics C++: A General Purpose Language and Library 01 | Getting Started 05

Course Topics C++: A General Purpose Language and Library 01 | Getting Started 05 | Pointers and RAII – Resource Acquisition is Initialization 02 | Fundamentals 06 | The C++ Standard Library, or STL 03 | The C++ Object Model 07 | Next Steps 04 | References and Inheritance

Setting Expectations • Target Audience – Has done some development in any other programming

Setting Expectations • Target Audience – Has done some development in any other programming language – Familiar with concepts like looping, conditional expressions – No need for any C++ background or any C-related language • Suggested Prerequisites/Supporting Material – Book: C++ Primer, 5 th Ed. , by Lippman, Lajoie, and Moo • Software and Tools – Microsoft Visual Studio Express 2013 for Windows Desktop – Free download • Sample Code available – http: //aka. ms/Code. CPlus. JS

Join the MVA Community! • Microsoft Virtual Academy – Free online learning tailored for

Join the MVA Community! • Microsoft Virtual Academy – Free online learning tailored for IT Pros and Developers – Over 1 M registered users – Up-to-date, relevant training on variety of Microsoft products • “Earn while you learn!” – Get 50 MVA Points for this event! – Visit http: //aka. ms/MVA-Voucher – Enter this code: CPlus (expires 12/20/2013)

01 | {Getting Started} Kate Gregory | Gregory Consulting James Mc. Nellis | Senior

01 | {Getting Started} Kate Gregory | Gregory Consulting James Mc. Nellis | Senior Engineer, Visual C++

Module Overview • Development Environment • How to write, build, and run code •

Module Overview • Development Environment • How to write, build, and run code • Quick History of C++ • Variables and Types

Lesson 1 – Development Environment • Development Environment

Lesson 1 – Development Environment • Development Environment

Development Environment • Visual Studio Express 2013 for Windows Desktop – It’s free and

Development Environment • Visual Studio Express 2013 for Windows Desktop – It’s free and it’s all you need to follow along • Not using Windows? – C++ works on other platforms too – http: //isocpp. org/get-started has links to compilers • Our sample code is available – LINK TBA

DEMO Hello, World!

DEMO Hello, World!

Lesson 2: How to Write, Build and Run Code • How code is built

Lesson 2: How to Write, Build and Run Code • How code is built • Structure of a C++ program • Debugging

The Compilation Process Preprocessor Compiler Linker • Takes your C++ source code and evaluates

The Compilation Process Preprocessor Compiler Linker • Takes your C++ source code and evaluates preprocessor directives. • Produces a preprocessed source file (but usually is just part of compiler). • Takes preprocessed source code, compiles into object files. • Checks that your code conforms to all syntax and semantic rules (e. g. , no type errors). • Accepts promises from the code about things defined in other source files. • Takes object files, links them into an executable program. • Ensures that all of the promises to the compiler are kept.

Structure of a C++ program #include <iostream> int main() { Use a library Special

Structure of a C++ program #include <iostream> int main() { Use a library Special function name that the OS calls to run your program std: : cout << "Hello, World!" << std: : endl; return 0; } std: : cout represents console output << means send the next thing to it

DEMO Building

DEMO Building

Debugging • Normally a console application – Starts – Executes the code in main()

Debugging • Normally a console application – Starts – Executes the code in main() – Might print to the console (or read from the keyboard) – Terminates (quits) • Under a debugger, you can pause execution – Inspect values – Watch execution proceed – Slower, but vital to understanding

DEMO Debugging

DEMO Debugging

Lesson 3: Quick History of C++ • Born in 1979 as C with Classes

Lesson 3: Quick History of C++ • Born in 1979 as C with Classes – Retains backward compatibility with C • Named C++ in 1983 • Ratified as ISO standard in 1998 • Continues to change under stewardship of a standards committee

Lesson 1: Types • C++ is strongly typed • Fundamental types • Casting (changing

Lesson 1: Types • C++ is strongly typed • Fundamental types • Casting (changing type)

DEMO Types

DEMO Types

Fundamental Types • Types you use a lot: – int, unsigned int – double

Fundamental Types • Types you use a lot: – int, unsigned int – double – bool • Types you may see – char, unsigned char – long, unsigned long – short, unsigned short – float • http: //msdn. microsoft. com/en-us/library/cc 953 fe 1. aspx

Casting • Instead of writing code that relies on the compiler to convert one

Casting • Instead of writing code that relies on the compiler to convert one type to another, you can ask for it explicitly • i = static_cast<int>(3. 2); • Makes a good “signpost” for others who read your code • Takes away compiler warnings – Always try to build warning free

DEMO Casting

DEMO Casting

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U. S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.