Introduction

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

Introduction to C++

C++ is a language that is similar to C#, it shares much of the syntax and formatting. This is due to C# having been created as an advancement on C++. A key difference that is essential to know is C# is protected, it is far harder to cause serious damage or make inefficient code that causes large slow downs, this differs to C++ which lacks this protection.

Despite the risks working in C++ allows for better interaction with hardware, and better manipulation for memory. This means that when programming something extremely large, or working directly with hardware C++ can be of more use, furthermore knowing C++ allows someone access to almost any aspect of programming.

Differences

C++ has a feature that is not within C#, Pointers. A pointer is a direct target at memory, this means that as opposed to recreating something such as an image or passing a reference to where the image is, the program can directly look at the memory; usually returning a hexadecimal string if written to the console.

C++ also has headers files with the classes. These files are where variables, methods and functions are all initialised, they then get filled within the class (C++) file.

C++ requires use of a few new operators such as the  :: , this operator is not introduced until university (where C++ is often introduced) and it is one of the most common causes for a program not compiling other then missing a semi-colon for programmers. Other operators are used, however they have different meanings based on the context they are used as the same symbols can be reassigned to completely different meanings.

C++ requires inclusion of many libraries for more basic things, simply outputting to the console requires the use of a library not included in visual studios default C++ template.