1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

1 CSCI N305 C Language Programming Welcome to CSCI N305! Compiling Your First Program Using Microsoft Visual Studio 2008.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
C Pre-Course Workshop Terence Lee QT406 -> PQ607
Programming Basics Aims of Programming: –The aim of programming is to write programs to accomplish complex tasks Programming method: –functional decompositional.
CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 1 Tariq Aziz and Kevin Jones.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
1 Writing a Good Program 5. Objects and Classes in C++
Compunet Corporation Programming with Visual Basic.NET GUI Week # 11 Tariq Ibn Aziz.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Course Introduction and Getting Started with C 1 USF - COP C for Engineers Summer 2008.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
1 3D Modelling with OpenGL Brian Farrimond Robina Hetherington.
Creating a Console Application with Visual Studio
Beginning Programming with the Visual Studio.NET Environment.
CHAPTER 1 XNA Game Studio 4.0. Your First Project A computer game is not just a program—it is also lots of other bits and pieces that make playing the.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
A First Program Using C#
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Introduction to VB.NET Tonga Institute of Higher Education.
Intro. to Game Programming Want to program a game?
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - HelloWorld Application: Introduction to.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Working with Unmanaged Code.
CS Tutorial 1 Getting Started with Visual Studio 2012 (Visual Studio 2010 are no longer available on MSDNAA, please choose Visual Studio 2012 which.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
IE 411/511: Visual Programming for Industrial Applications
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 1 Quick Introduction The following.
1 ITI 1120 Lab # 1 An Introduction to the Lab Environment Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot.
Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble.
Introduction In The Name Of Allah, The Beneficent, The Merciful.
Active-HDL Interfaces Debugging C Code Course 10.
Active-HDL Interfaces Building VHPI Applications C Compilation Course 9.
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
Using Microsoft Visual Studio C++ Express 2005 Name: Dr Ju Wang Ashwin Belle Course Resource:
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Programming with Visual Studio.NET A short review of the process.
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
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.
CSC 157 (Blum)1 Hello World. CSC 157 (Blum)2 Start/Programs/Microsoft Visual Studio.NET 2003/Microsoft Visual Studio.NET 2003.
Compiling a Native C++ Program on the Command Line #define #include.
Operating Systems Written by: Tim Keyser Georgia CTAE Resource Network 2010.
® Microsoft Office 2010 Exploring the Basics of Microsoft Windows 7.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
C Copyright © 2009, Oracle. All rights reserved. Using SQL Developer.
Tutorial 1 Writing Your First C++ Program CSC1110C Introduction to Computer Programming By Paul Pun Acknowledgement: Special thanks to Dr. Michael Fung.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Dive Into® Visual Basic 2010 Express
Chapter 2: The Visual Studio .NET Development Environment
Computer Terms Review from what language did C++ originate?
Computer Programming Lecturer: Ir Dr Frank H.F. LEUNG
Social Media And Global Computing Introduction to Visual Studio
Understanding the Visual IDE
1. Open Visual Studio 2008.
ms vısual studıo 2008-Introductıon TUTORIAL
Lab 1 Introduction to C++.
Creating Your First C Program Using Visual Studio 2010
Creating Your First C Program Using Visual Studio 2010
Double click Microsoft Visual Studio 2010 on the Computer Desktop
POS 408 Week 1 Individual Assignment Individual: Console Display Message//tutorfortune.com Click on below link to buy
Presentation transcript:

1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY

2 Programming Environment Before doing any C++ programming, first we need to familiarize with the programming environment. A programming environment is a software package that can help us develop and test program codes. For PC, one of the most popular programming environments is Microsoft Visual Studio. It is more popular because of its direct support to the Microsoft Windows environment. Computer Programming and Basic Software Engineering 2. A Taste of C++

3 Computer Programming and Basic Software Engineering 2. A Taste of C++ Visual C++ is one of the components of the umbrella product – Visual Studio, which also contains development tools for other programming languages, e.g. Visual Basic, Visual J++, etc. Visual Studio has been for sale for more than 10 years. The latest version is Visual Studio.NET. The C++ compiler that is incorporated is Visual C++.NET. Additional features include Produce managed codes that run in the.NET runtime Allow the use of.NET class library. Visual Studio.NET Second semester

4 Visual Studio – Solution and Project In Visual Studio, each user task is referred to as a solution to a problem. A solution refers to the computer resource (such as memory, disk space, etc.) required for one or more projects to complete the task. Every project contains executable code and debug information files containing the C++ programs classes and objects used in the project other related resources such as icon images used in the project graphical user interface (GUI), e.g. button, menu. Computer Programming and Basic Software Engineering 2. A Taste of C++ They are all in files

5 Computer Programming and Basic Software Engineering 2. A Taste of C++ Solution Project 1 Project 2 Project 3 Files A Solution must contain at least one Project A Project must contain at least one File

6 Source Program Editing Display compilation results Display resources of the solution, such as, projects and files inside Computer Programming and Basic Software Engineering 2. A Taste of C++

7 Visual Studio - Project Example Solution Explorer allows us to clearly see the different files included in the project Computer Programming and Basic Software Engineering 2. A Taste of C++

8 Visual Studio - Project Example Program can be typed here Computer Programming and Basic Software Engineering 2. A Taste of C++ Built result (result of compiling and linking) shown here

9 Build your first project - HelloWorld Building a project means to produce target executable files (.exe files) based on the program codes. Project can be built to execute in console or windows mode Console mode: Use the Command Prompt for in/output Windows mode: Use the Windows environment for program execution. Computer Programming and Basic Software Engineering 2. A Taste of C++ Second semester

10 Computer Programming and Basic Software Engineering 2. A Taste of C++ Command Prompt It is a traditional interface between the user and computer User types in commands to instruct computer to work.

11 Build your first project - HelloWorld #include int main() { std::cout << "Hello World!" << std::endl; return 0; } Hello.cpp : File containing a C++ program that prints a message “Hello World!” on the console output. Computer Programming and Basic Software Engineering 2. A Taste of C++ The returned type of main() must be declared in Visual Studio.NET 2005

12 Computer Programming and Basic Software Engineering 2. A Taste of C++ Step 1: Start the Visual Studio.NET 2005 Click New Project

13 Computer Programming and Basic Software Engineering 2. A Taste of C++ Step 2 Note where you create this project You can modify the location of the files of your project.

14 Computer Programming and Basic Software Engineering 2. A Taste of C++ Step 3

15 Computer Programming and Basic Software Engineering 2. A Taste of C++ Step 4: Right-click Source Files, select Add → New Item

16 Computer Programming and Basic Software Engineering 2. A Taste of C++ Step 5: Choose C++ File (.cpp). Give a name to the C++ file you are going to add

17 Computer Programming and Basic Software Engineering 2. A Taste of C++ Step 6: Type the program on p.11 here. Click Build → Build Solution See the built result

18 Computer Programming and Basic Software Engineering 2. A Taste of C++ Do you see the following result? Note: The result is shown in the Command Prompt – Console Application Step 7: Execute the program by clicking Debug → Start Without Debugging

19 Computer Programming and Basic Software Engineering 2. A Taste of C++ What has actually done? In the HelloWorld example, one solution is created that contains a project called chap2p1. Inside the project, there is one C++ program called Hello.cpp. Solution Project: chap2p1 C++ File: Hello.cpp

20 Computer Programming and Basic Software Engineering 2. A Taste of C++ The C++ Compiler of Visual Studio compiles the program Hello.cpp and generates an executable file chap2p1.exe. When you click Debug → Start Without Debugging, Visual Studio actually runs the executable file chap2p1.exe for you. All files generated in this project is stored in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\chap2p1 Run Windows Explorer

21 2. A Taste of C++ Computer Programming and Basic Software Engineering Contains all files created after building the solution Contains info. about the project. Double-click this will automatically start the project The C++ file you created

22 Computer Programming and Basic Software Engineering 2. A Taste of C++ The EXE (executable) file created

23 Computer Programming and Basic Software Engineering 2. A Taste of C++ We can always run the program under the command prompt

24 Exercise 2.1 Consider the two programs on the RHS. For each of the program, construct a new project in Visual Studio and then build the solution. For each program, note the error messages when building the project. Fix the errors and execute the resulting project. What do you see? #include int main() cout << "Hi World!" << std::endl; return 0; } #include int test() { std::cout << "How are you!" << std::endl; return 0; } Computer Programming and Basic Software Engineering 2. A Taste of C++

25 Exercise Open the Command Prompt. 2.By using the command cd, change the current folder to the folder that contains chap2p1.exe (you may want to use the command dir to show the content of a folder.) 3.Run chap2p1.exe by typing its file name and press Enter. 4.Compare the result with that you run the program in Visual Studio. Can you see any difference coming up? 5.If no, add the following lines of code before “ return 0 ;” of Hello.cpp. std::cout<<"Press Enter to continue."<<std::endl; std::cin.get(); Rebuild the solution. Repeat 1 to 4 and note any difference. Computer Programming and Basic Software Engineering 2. A Taste of C++

26 Acknowledgment The slides are based on the set developed by Dr. Frank Leung (EIE).