1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple...

26
1 Getting Started with C++

Transcript of 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple...

Page 1: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

1

Getting Started with C++

Page 2: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

2

Objective

You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008

Page 3: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

3

Start Up Visual Studio 2008Click

Page 4: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

4

Visual Studio Projects

A project in Visual Studio is a container for all of the files needed to compile, execute, and debug a program.

A solution can consist of multiple related projects.

Our solutions will only have a single project. So a solution and a project will be essentially

equivalent in this course.

Page 5: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

5

Ready to Create a Project

Page 6: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

6

Creating a C++ Project in Visual Studio 2008

Page 7: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

7

Creating a C++ Project in Visual Studio 2008

Click

Page 8: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

8

Creating a C++ Project in Visual Studio 2008

Click

Page 9: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

9

Start with an Empty Project

Click

Click

Page 10: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

10

We Have a Project

Page 11: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

11

Adding a Source File to the Project

Page 12: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

12

Adding a Source File to the Project

Click

Page 13: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

13

It's Open in the Editor

Page 14: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

14

Add the Program Code

Page 15: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

15

View the Solution Explorer

Page 16: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

16

Solution Explorer Window

Page 17: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

17

Compile and Link the Program

Page 18: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

18

Run the Program

Click here to run

Page 19: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

19

Program "hello.cpp" in Action

Press "Enter" to end program and close window.

Page 20: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

20

Running Without the IDE

We can double click here to run the program independently of the IDE.

Here is the exe file.

Page 21: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

Running from the Desktop

Drag the hello.exe icon to the desktop.

Double click the icon to run the program from the desktop.

21

Page 22: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

22

Running Without the IDE

We can also run the program from the DOS command line.

Copy the exe file into a convenient directory (e.g. C )

Open a command window cd to the directory Type the command: hello

Page 23: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

23

Running from the Command Line

Page 24: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

24

Deploying the Program

The file hello.exe contains everything that is needed to execute the program.

To deploy the program to another Windows computer, just copy the file into a convenient folder.

Users can run the program from the command line, or can double click the file in the folder. Or can put a shortcut to the file on the desktop.

Page 25: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

25

Creating a Shortcut

Page 26: 1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.

26

Running by Double Clicking

Move the shortcut to the desktop.

Now you can run the program by double clicking the icon.