20
C++ Introduction : C++ compilation

C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Embed Size (px)

Citation preview

Page 1: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

C++ Introduction :C++ compilation

Page 2: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Visual Studio 2008 : Creating Command-Line Program

Page 3: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Visual Studio 2008Creating Command-Line Program

Page 4: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Visual Studio 2008Creating Command-Line Program

Page 5: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Visual Studio 2008Creating Command-Line Program

Page 6: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Visual Studio 2008Creating Command-Line Program

Page 7: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

C++ Introduction :C++ program structure

Page 8: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

• It is OK to use C code in C++ pro-gram

Page 9: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

C++ Introduction :C++ Standard Input/Output

Page 10: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Standard Output (cout)

• cout : screen stream object

Page 11: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

Standard Input (cin)

• cin : keyboard stream object

Page 12: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

C++ Introduction : Func-tions

Page 13: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

C++ Introduction : array/pointer/dynamic allocation

• Array/Pointer : almost same as C• Dynamic allocation–malloc (in C) new (in C++)– free (in C) delete (in C++)

Ex) in Cint *x;x=(int*)malloc(10*sizeof(int));

free(x);

Ex) in C++int *x;x=new int[10];

delete[] x;

Page 14: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

C++ Introduction :C++ class

Page 15: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

class• class : data structure type that can contain

member data and member functions.

Page 16: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

• class constructor/destructor – member function that is automatically called

when the object is created/deleted.

Page 17: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

• pointers to class object

Page 18: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

C++ Introduction :Input/Output with Files

Page 19: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

• file stream class– ofstream: stream class to write on files– ifstream: stream class to read from files– fstream: stream class to reaad and write from/to

files

Page 20: C++ Introduction : C++ compilation. Visual Studio 2008 : Creating Command-Line Program

File open mode