before going into code we need first to settle some important informations
C++ is originally called C with classes so it’s really a subset of C , however C++ have a lot more Features than C ; including some basic things like inputs and outputs
do you mean that Scanf () and printf() and getche() works in C++ ? yeah they do =) actually all C functions do work on C++
Great so that means we don’t need to read about functions , arrays and all the C stuff ,,, yeah however we will elaborate some important things and offcourse things related to data structure
so let’s code :
in the begining this is a let’s describe how to configure visual studio for a hello world program ,and a sample code to make a simple hello world program
the source code project from here : Download
- click on console application and empty project
- then on the right click on the solution explorer
- if you cant find the solution explorer click show it from View next to file in the menu or click cntrl +alt + L
-
and write the following in the main file
-
#include <iostream> using namespace std ; void main () { cout << "hello world " ; }
-
click cntrl +f5 to run
NOTES :
- #include <iostream> // this to include the libraries for console output .. has alot of similarities with stdio.h “standard input and output” library in C
- using .. this keyword in C++ is like we say assume that we are using , the following so we write using namespace std , in order not to say std::cout and write cout alone , (we will explain what’s the name space later on )
- cout is like printf it takes a string and prints it into the console