introduction to programming and visual c
Download
Skip this Video
Download Presentation
Introduction to Programming and Visual C++

Loading in 2 Seconds...

play fullscreen
1 / 57

Introduction to Programming and Visual C++ - PowerPoint PPT Presentation


  • 330 Views
  • Uploaded on

Introduction to Programming and Visual C++ Objectives In this chapter you will learn about: Computer programming and programming languages C/C++ programming Logic and debugging Creating a new project in Visual C++ The Visual Studio IDE Managing the solution Visual C++ Help

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Introduction to Programming and Visual C++' - Gabriel


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction to programming and visual c

Introduction to Programming and Visual C++

Microsoft Visual C++ .NET Chapter 1

objectives
Objectives

In this chapter you will learn about:

  • Computer programming and programming languages
  • C/C++ programming
  • Logic and debugging
  • Creating a new project in Visual C++
  • The Visual Studio IDE
  • Managing the solution
  • Visual C++ Help

Microsoft Visual C++ .NET Chapter 1

computer programming and programming languages
Computer Programming and Programming Languages
  • Creating instructions that control the operation of a computer or computer hardware is called computer programming
  • The instructions themselves are called computer programs, applications, software, or simply programs
  • The pieces of information that a program needs are called data

Microsoft Visual C++ .NET Chapter 1

machine and assembly languages
Machine and Assembly Languages
  • Telling a computer what to do involves writing programs that set these switches to on or off
  • Machine language is the lowest level of computer languages, and programs written in machine language consist entirely of 1s and 0s that control the computer’s on and off switches
  • A program written in machine language may contain lines similar to the example shown at the top of page 3 in the textbook

Microsoft Visual C++ .NET Chapter 1

machine and assembly languages5
Machine and Assembly Languages
  • Writing a program in machine language is very difficult because you must understand how the exact placement and combination of 1s and 0s will affect your program
  • Assembly languages perform the same tasks as machine languages, but use simplified names of instructions instead of 1s and 0s

Microsoft Visual C++ .NET Chapter 1

machine and assembly languages6
Machine and Assembly Languages
  • Machine languages and assembly languages are known as low-level languages because they are the programming languages that are closest to a computer’s hardware
  • Each type of central processing unit (CPU) contains its own internal machine language and assembly language

Microsoft Visual C++ .NET Chapter 1

high level programming languages
High-Level Programming Languages
  • High-level programming languages create computer programs using instructions that are much easier to understand than machine or assembly language code because you use words that more clearly describe the task being performed
  • Examples of high-level languages include C++, BASIC, and COBOL

Microsoft Visual C++ .NET Chapter 1

high level programming languages8
High-Level Programming Languages
  • Another advantage to high-level programming languages is that they are not CPU-specific, as are machine and assembly languages
  • However, in order to run, programs written in high-level languages must first be translated into a low-level language using a program called a compiler
  • A compiler translates programming code into a low-level format

Microsoft Visual C++ .NET Chapter 1

procedural programming
Procedural Programming
  • One of the most common forms of programming in high-level languages is called procedural programming
  • In procedural programming, computer instructions are often grouped into logical units called procedures
  • In C++ programming, procedures are referred to as functions

Microsoft Visual C++ .NET Chapter 1

procedural programming10
Procedural Programming
  • Each line in a procedural program that performs an individual task is called a statement
  • When a procedure or function is referred to in the book, its name is usually followed by two parentheses, as in balanceCheckbook()
  • One of the most important aspects of procedural programming is that it allows you to temporarily store pieces of data in computer memory locations called variables

Microsoft Visual C++ .NET Chapter 1

procedural programming11
Procedural Programming
  • The information contained in a specific variable often changes
  • Another form of data that you can store in computer memory locations is a constant
  • A constant contains information that does not change during the course of program execution

Microsoft Visual C++ .NET Chapter 1

object oriented programming
Object-Oriented Programming
  • Object-oriented programming (OOP) refers to the creation of reusable software objects that can be easily incorporated into another program
  • Reusable software objects are often referred to as components
  • In object-oriented programming, an object is programming code and data that can be treated as an individual unit or component

Microsoft Visual C++ .NET Chapter 1

object oriented programming13
Object-Oriented Programming
  • Data refers to information contained within variables, constants, or other types of storage structures
  • The functions associated with an object are referred to as methods
  • Variables that are associated with an object are referred to as properties or attributes
  • Objects can range from simple controls, such as a button, to entire programs, such as a database application

Microsoft Visual C++ .NET Chapter 1

object oriented programming14
Object-Oriented Programming
  • Objects are encapsulated, which means that all code and required data are contained within the object itself
  • Encapsulation is also referred to as a black box, because of the invisibility of the code inside an encapsulated object
  • An interface represents elements required for a source program to communicate with an object
  • Interface elements required to access a Payroll object might be a method named calcNetPay(), which calculates an employee’s net pay and properties containing the employee’s name and pay rate

Microsoft Visual C++ .NET Chapter 1

object oriented programming15
Object-Oriented Programming
  • Another example of an object and its interface is a Windows word-processing program
  • In object-oriented programming, the code, methods, attributes, and other information that make up an object are contained in a structure known as a class
  • Programming objects are created from classes

Microsoft Visual C++ .NET Chapter 1

object oriented programming16
Object-Oriented Programming
  • When you use an object in your programs, you actually create an instance of the class of the object
  • An instance is an object that has been created from an existing class
  • Inheritance refers to the ability of an object to take on the characteristics of the class on which it is based

Microsoft Visual C++ .NET Chapter 1

c c programming
C/C++ Programming
  • The term C/C++ refers to two separate, but related, programming languages: C and C++
  • You create C and C++ programs in text files using a text-editing tool such as Notepad
  • The original program structure you enter into a text file is referred to as source code
  • The compiled machine language version of a program is called object code

Microsoft Visual C++ .NET Chapter 1

c c programming18
C/C++ Programming
  • Once you compile a program into object code, some systems require you to use a program called a linker, which converts the object code into an executable file, typically with an extension of .exe
  • Figure 1-6 in the text uses a simple program that prints the text Hello World to a console application window to show how source code is transformed into object code and then into an executable process

Microsoft Visual C++ .NET Chapter 1

c c programming19
C/C++ Programming
  • In Visual C++, you compile and link a program in a single step known as building
  • Remember that each computer contains its own internal machine language
  • The C/C++ compiler you use must be able to translate source code into the machine language of the computer, or platform, on which your program will run
  • A platform is an operating system and its hardware type

Microsoft Visual C++ .NET Chapter 1

the c programming language
The C Programming Language
  • One of the most important programs created with the original C language was the UNIX operating system
  • To provide a level of standardization for the C language, in 1989 the American National Standards Institute (ANSI) created a standardized version of C that is commonly referred to as ANSI C

Microsoft Visual C++ .NET Chapter 1

the c programming language21
The C++ Programming Language
  • C++ is currently the most popular programming language for developing graphical programs that run on platforms such as Macintosh and Windows
  • Graphical programs refers to programs with visual components such as dialog boxes, menus, toolbars, and so on
  • C++ has the ability to create graphical programs because of the object-oriented programming capabilities added by Stroustrup when he first developed the language from its C predecessor

Microsoft Visual C++ .NET Chapter 1

the c programming language22
The C++ Programming Language
  • The standardized version of C++ is commonly referred to as ANSI C++
  • The ANSI C++ standard ensures that programs written in C++ are compatible with different compilers and can be run on different platforms
  • The ANSI C and ANSI C++ standards define how C/C++ code can be written

Microsoft Visual C++ .NET Chapter 1

the c programming language23
The C++ Programming Language
  • The ANSI standards also define run-time libraries, which contain useful functions, variables, constants, and other programmatic items that you can add to your programs
  • The ANSI C++ run-time library is also called the Standard Template Library or Standard C++ Library
  • Most of the features of C are also available in C++, which means you can use C++ to write both procedural and object-oriented programs

Microsoft Visual C++ .NET Chapter 1

visual c net
Visual C++.NET
  • Microsoft Visual C++.NET, or Visual C++ for short, is a Windows-based, visual development environment for creating C and C++ applications
  • It is part of the Microsoft Visual Studio line of products
  • Visual C++ contains a built-in code editor, compiler, and other tools for creating programs
  • Actually, Visual C++ itself is not a programming language

Microsoft Visual C++ .NET Chapter 1

visual c net25
Visual C++.NET
  • It is a development environment used for creating programs with the C/C++ languages
  • Visual C++ supports a number of extensions to the ANSI C/C++ run-time libraries
  • Extensions are new or additional features that have been added to the original run-time libraries
  • Visual C++ extensions may or may not be supported by other C/C++ compilers, so you cannot be absolutely certain that any programs you write that use the extensions will be able to run on other platforms

Microsoft Visual C++ .NET Chapter 1

visual c net26
Visual C++.NET
  • Visual C++ extends the C++ language by allowing you to include Microsoft Foundation Classes in your programs
  • Microsoft Foundation Classes (MFCs) are libraries of classes that can be used as the building blocks for creating Windows applications with Visual C++
  • The Microsoft Visual Studio line of development tools includes a platform called the .NET Framework that is designed for developing and running Internet applications, primarily Web-based applications and services

Microsoft Visual C++ .NET Chapter 1

visual c net27
Visual C++.NET
  • As part of the .NET Framework, Microsoft has introduced a new programming language, C# (pronounced “C sharp”)
  • C# is an object-oriented programming language based on C/C++ that creates Web-based programs designed to run on the .NET Framework
  • Managed Extensions are special sets of code that allow traditional C++ programs to function on the .NET Framework

Microsoft Visual C++ .NET Chapter 1

logic and debugging
Logic and Debugging
  • Each high-level programming language, including Visual C++, has its own syntax, or rules of the language
  • The logic underlying any program involves executing the various parts of the program in the correct order to produce the desired results
  • Any error in a program that prevents if from compiling or causes it to function incorrectly, whether due to incorrect syntax or flaws in logic, is called a bug

Microsoft Visual C++ .NET Chapter 1

logic and debugging29
Logic and Debugging
  • Debugging describes the act of tracing and resolving errors in a program
  • Do not confuse bugs with computer viruses
  • Bugs are errors within a program that occur because of syntax errors, design flaws, and other types of errors
  • Visual C++ contains many debugging commands and features, which you will learn about in Chapter 4

Microsoft Visual C++ .NET Chapter 1

creating a new project in visual c
Creating a New Project in Visual C++
  • You will need to store the applications you create in a folder on your hard drive or on a network drive with sufficient disk space
  • Next, you will create a projects folder named Visual C++ Projects, or some other name that makes sense to you
  • To create a projects folder for your Visual C++ projects, use the steps referred to on page 16 of the textbook

Microsoft Visual C++ .NET Chapter 1

the visual studio ide
The Visual Studio IDE
  • Visual C++, Visual Basic, Visual C#, and the MSDN Library share a common workspace in Visual Studio called the Integrated Development Environment (IDE)
  • For each instance of the IDE there is a single solution containing one or more projects
  • A project is the application you are creating
  • A solution is also an application, but it is composed of one or more projects

Microsoft Visual C++ .NET Chapter 1

the visual studio ide32
The Visual Studio IDE
  • Projects can be part of one solution or part of more than one solution
  • They can be opened individually within a new solution or as part of an existing solution
  • For the rest of this chapter, you will use the HelloWorld project to learn how to work with several of the basic development tools and windows that are available to a Visual C++ application

Microsoft Visual C++ .NET Chapter 1

the start page
The Start Page
  • The Start Page appears by default in the IDE whenever you first start Visual Studio
  • The Start Page allows you to set IDE user preferences and acts as a Web browser window
  • Links within the Start Page provide quick access to MSDN Online Web pages and newsgroups
  • The links within the Start Page window are as shown on page 20 of the textbook

Microsoft Visual C++ .NET Chapter 1

the solution explorer window
The Solution Explorer Window
  • Visual C++ projects are normally composed of multiple files representing a specific type of resource or object
  • Two of the most common types of files you will use in Visual C++ are C++ source files, with an extension of .cpp, and C++ header files, with an extension of .h
  • You use the Solution Explorer window in the IDE to manage the various projects and associated files contained in a solution

Microsoft Visual C++ .NET Chapter 1

the solution explorer window35
The Solution Explorer Window
  • Notice the three tabs that are visible at the bottom of the Solution Explorer window: Solution Explorer, Class View, and Resource View
  • Class View displays project files according to their classes, which are arranged as folders in the project directory
  • Resource View displays the files that are used specifically for building a Windows application

Microsoft Visual C++ .NET Chapter 1

the code and text editor window
The Code and Text Editor Window
  • Visual C++ has its own built-in editor called the Code and Text Editor window
  • Some of the features of the Code and Text Editor window apply only to objects that are part of your C++ code
  • The Code and Text Editor window is called the Code Editor when it displays programming code, and it is called the Text Editor when it displays text that is not associated with any particular programming language

Microsoft Visual C++ .NET Chapter 1

the code and text editor window37
The Code and Text Editor Window
  • The various types of code elements in the Code Editor window are distinguished by syntax coloring
  • The Code Editor window uses a feature called statement completion to aid in the creation of C++ code
  • As you are writing code, member lists and parameter information are displayed automatically according to the current object

Microsoft Visual C++ .NET Chapter 1

project properties
Project Properties
  • A Visual C++ project contains various settings, or properties, that determine how the project appears and behaves
  • You use the Property Pages dialog box to change the properties of a project
  • In order to access the Property Pages dialog box for a particular project, you must have the project selected in the Solution Explorer window

Microsoft Visual C++ .NET Chapter 1

building and executing an application
Building and Executing an Application
  • The tools for compiling a C++ program are located on the Build menu
  • You have three options for compiling an application: compile C++ source files individually using the Compile command; compile individual projects using the Build command; or compile all the source files and projects in a solution using the Build Solution command

Microsoft Visual C++ .NET Chapter 1

building and executing an application40
Building and Executing an Application
  • You use the Compile command when you want to check your syntax while you are writing code
  • However, you must execute the Build or Build Solution command at least once in order to create an executable file
  • For small programs, it is usually easier to select one of the Build commands so that the program is compiled and built in a single step

Microsoft Visual C++ .NET Chapter 1

building and executing an application41
Building and Executing an Application
  • When you select one of the Build commands, Visual C++ compiles only the files in any of your projects that have changed
  • However, there may be instances when you must recompile your program, even if you have made no changes to the code
  • For example, you would need to recompile your entire program if your compiled files became corrupt or if you wanted to perform some final testing before releasing a finished version of your program

Microsoft Visual C++ .NET Chapter 1

the output window
The Output Window
  • At the bottom of the IDE is the Output window
  • Visual C++ uses the Output window to display its progress when you build a program
  • The Output window also displays build messages for any types of errors that Visual C++ finds during the build process

Microsoft Visual C++ .NET Chapter 1

the task list
The Task List
  • Located next to the Output window in the IDE is the Task List, which maintains a list of tasks that need to be completed for a project
  • The Task List also shows build messages for errors that Visual C++ finds during the build process
  • Unlike the Output window, which shows build messages as static text, the Task List shows build messages as tasks that need to be completed

Microsoft Visual C++ .NET Chapter 1

the task list44
The Task List
  • Warning messages occur for any potential problems that may exist in your code, but that are not serious enough to cause a compiler error message

Microsoft Visual C++ .NET Chapter 1

the task list45
The Task List
  • The number and severity of warning messages is determined by the Warning Level setting in the C++ folder of the Project Properties dialog box
  • Figure 1-23 lists the warning levels and their descriptions
  • Until you are a more experienced programmer, you should leave your warning level set to the default setting of Level 3

Microsoft Visual C++ .NET Chapter 1

adding resources to a project
Adding Resources to a Project
  • The various resources that make up projects and solutions are contained in disk files
  • It is important that you realize that although a file may be stored in the same folder where other files in a project are stored, the file will not actually be a part of the project until you physically add it to the project within the Visual C++ IDE
  • For example, consider the Solution Explorer window in Figure 1-28 in the text

Microsoft Visual C++ .NET Chapter 1

adding projects to a solution
Adding Projects to a Solution
  • Solutions are composed of one or more projects
  • You can add new or existing projects to a solution
  • To add a new project to the current solution, perform the steps illustrated on page 43 of the textbook
  • You can also add an existing project by pointing to Add Project on the File menu and then selecting the Existing Project command

Microsoft Visual C++ .NET Chapter 1

saving solutions projects and files
Saving Solutions, Projects, and Files
  • As you are developing a project and solution, you need to compile and execute your programs to make sure they perform as you would like
  • By default, Visual C++ saves changes to all open documents during the build process
  • However, you must save manually if you make changes to a file contained in a project and then close the file or project without building
  • You can also save solutions, projects, and individual files by clicking the Save icon on the Standard toolbar or by pressing Ctrl+S

Microsoft Visual C++ .NET Chapter 1

closing solutions projects and files
Closing Solutions, Projects, and Files
  • If you have multiple projects and files open, the Visual C++ IDE can become difficult to work with because the screen may become crowded
  • Therefore, you may find it necessary to close individual projects and files when you are through working with them
  • To close the Hello World solution, follow the instructions on page 45 of the textbook

Microsoft Visual C++ .NET Chapter 1

visual c help
Visual C++ Help
  • As you work in Visual C++, there will be many times when you will need to quickly access Help on a particular subject
  • When you are working with toolbar buttons, it is easy to forget what command a particular button represents
  • Tool Tips describe the functions buttons perform and can be momentarily displayed next to your mouse pointer for individual buttons

Microsoft Visual C++ .NET Chapter 1

visual c help51
Visual C++ Help
  • For advanced help and reference information, Visual C++ has an online help system, called the MSDN Library
  • You display the MSDN Library from the IDE by selecting one of the following commands on the Help menu: Contents, Index, Search, Favorites, Index results, or Search results
  • The Table of Contents window contains four tabs: Contents, Index, Search, and Favorites

Microsoft Visual C++ .NET Chapter 1

visual c help52
Visual C++ Help
  • The Contents tab contains help topics in a table of contents format that is very similar to folders in Windows Explorer or the Solution Explorer window
  • The Index tab is used for browsing a list of key words and topics
  • The Search tab allows you to search for a particular word or phrase
  • The Favorites tab contains your bookmarks for topics of particular interest to you

Microsoft Visual C++ .NET Chapter 1

visual c help53
Visual C++ Help
  • Help topics selected in any of the Table of Contents window tabs are displayed in the Topic window, which is the pane to the right of the Table of Contents window
  • MSDN Library also displays context-sensitive help for dialog boxes and programming terms
  • Dynamic help displays a list of help topics that are relevant to the current window or task
  • You can display the Dynamic Help window in the IDE by pressing Ctrl+F1 or by selecting Dynamic Help from the Help menu

Microsoft Visual C++ .NET Chapter 1

summary
Summary
  • Object-oriented programming (OOP) refers to the creation of reusable software objects that can be easily incorporated into other programs
  • Objects are encapsulated, which means that all code and required data are contained within the object itself
  • Inheritance refers to the ability of an object to take on the characteristics of the class on which it is based

Microsoft Visual C++ .NET Chapter 1

summary55
Summary
  • The ANSI C++ run-time library is also called the Standard Template Library or Standard C++ Library
  • Microsoft Visual C++.NET, or Visual C++ for short, is a Windows-based, visual development environment for creating C and C++ applications
  • Debugging describes the act of tracing and resolving errors in a program
  • The development products in Visual Studio share a common workspace in Visual Studio, called the Integrated Development Environment (IDE)

Microsoft Visual C++ .NET Chapter 1

summary56
Summary
  • For each instance of the IDE there is a single solution containing one or more projects
  • Visual C++ has its own built-in text editor called the Code and Text Editor window
  • The tools for compiling a C++ program are located on the Build menu
  • Visual C++ uses the Output window to display its progress when you build a program

Microsoft Visual C++ .NET Chapter 1

summary57
Summary
  • Tool Tips describe the function a button performs and can be momentarily displayed next to your mouse pointer for individual buttons
  • MSDN Library also displays context-sensitive help for dialog boxes and programming terms
  • Dynamic help displays a list of help topics that are relevant to the current window or task

Microsoft Visual C++ .NET Chapter 1

ad