Ana səhifə

How to Compile C++ code in Microsoft Visual Studio 2005


Yüklə 34 Kb.
tarix18.07.2016
ölçüsü34 Kb.

How to Compile C++ code in Microsoft Visual Studio 2005

In order to compile simple C++ program in Microsoft Visual Studio 2005, you need to follow the following steps:

  1. Create a new project. Choose Win 32 and Win 32 Console Application.

  2. Enter a name in the Name box below.

  3. Now press the Next button and then the Finish button.

  4. This will generate a file called name.cpp where name is your entered project name.

  5. Delete everything from the name.cpp file except the line “#include "stdafx.h"” and then include the following two lines at the beginning of the source code.

#include

using namespace std;



  1. Write your code

  2. Press F7 To compile. Note, you may get an error message that say "fatal error C1853: 'Debug\name.pch' precompiled header file is from a previous version of the compiler,

or the precompiled header is C++ and you are using it from C (or vice versa)"

  1. How to solve fatal error C1853: Right-click on your C++ file in Solution Explorer panel, and go to Properties dialog. Then change the value of C/C++ -> Precompiled Header -> Create/Use Precompiled Header field to "Not Using Precompiled Header".

  2. Run the program by pressing CTRL+F5

An example is given below:


#include

using namespace std;


class shs

{

private:



int n1;

int n2;


public:

shs(){ n1=3; n2=6; }

int add(int x, int y){return (x+y);}

int add(){ return (n1+n2);}

int access(){return n1;}

int addref (shs&);

};
int addref(shs& c)

{return (c.add() + c.add()); }


int main(){

shs a;


shs b;

cout << a.add(4,5);

return 0;}

How to debug in Visual C++ 2005 Express Edition:

========================================

1. F9 to insert break points

2. F5 to start debugging

3. F10 or F11 for step forward

5. F7 to stop debugging

How to Run C++ source code in Visual C++ 2005 Express Edition:

==========================================

1. Ctrl+F7 or F7 to compile and linking

2. Ctrl+F5 to run or execute
How to turn on line numbers in the editor:

==================================



1. Go to: Tools -> Options -> Text Editor -> C/C++ -> General

2. Check the box "Line Numbers" -> OK


Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016
rəhbərliyinə müraciət