Like this page!
facebook
twitter
google
google
<<< Previous1 2 3 4 5 6 7 8 9 10 11 12 13 Next >>>




Page number: 5

C++11


Another thing to note is that every library which ends with .c for example math.c is derived from the C language and is still that old. Even if that might be years ago which was created, it can actually be used in C++.
The new standard implemented is known as C++11. There is a lot of improvements there are not really too much which you would be afraid of. Actually, it is known as better for beginners. You will benefit a lot from it since it is clearer and it can be written in a more user friendly. Even though it was thought to be implemented on 2015, the programmers already did their job since 2011!

The new features will be better and easier to understand for those who just started programming in C++. The previous changes C++ had were implemented back in 2003. This means that new standards will need a lot of years before they change. When a new standard is implemented, it doesnít actually mean that what you know is lost forever, but it can also be used in the exact same way as you did know before. Just in case you want to know, the C language last standard was back in 1999 and is known as C99. This is the exact same meaning of C++11, because it was implemented in 2011.
In case you have Visual Studio 2012 or Codeblocks, you can actually use the new features. When it comes to Dev-Shed C++, that is quite old and I donít think it can really support those features. Also, be sure to download the latest Codeblocks version as it actually has the C++11 features. You will just have to enable them. Visual Studio has already enabled the features.

Now letís return to our little program. I told you before that there are more ways of showing in your screen monitor the same words. When outputting something on the screen it is known as printing out in a more scientific way. Try to execute this example:

#include <iostream>

using namespace std;

int main(){
cout << "Hello";
cout << "World!";
cout << endl;
}

It is clear now that you can break your code up into more pieces in case you want to add something later on in between. If you try to execute it, you will find out that it is HelloWorld! without any space in between. This happens only because our example didnít have any space after the Hello and this is a way you can actually call as a control to your program. I will show you how to get rid of this problem and you will understand for yourself. Whatever you put inside the double quotes is renowned as a String. A string is a group of characters and can also be a single character. The funny thing is that even the space is a character! It will print out on the screen every single character, no matter what it is. You cannot use any weird characters in case your IDE does not support them and you are trying to add characters which take up to 8 bytes, like the Japanase Kanji system.

For now, just add a space after the word Hello and see the result yourself. This will work even if you add a space before the World! It is quite simple and if you tried stuff like this before, you will soon understand yourself. The code we used is actually very bad and for now it just doesnít make any sense why to code like that. We will use a new way of codding and it will be better! Try this example:
#include <iostream>

using namespace std;

int main(){
cout << "Hello "
<< "World!"
<< endl;
}

What this actually is, is just a way of telling the compiler not to break the operation. This is because the semicolumn is at endl; and that is when our software will stop executing. The compiler is actually the software which uses and translates our code into machine code (the code of computers with 0 and 1).
This might seem really absurd, but it is quite obvious. Before we used << endl; in the same line of code. This means that all this can be sum up into one single line like this:

#include <iostream>

using namespace std;

int main(){
cout << "Hello " << "World!" << endl;
}


It actually works. The method with three lines of codes is suitable when you have very large text and want to add in as neat and clear as possible. The above example can be translated into the known better way: cout << "Hello World!" << endl;

They give us the same output, but there are some reasons in why there are different kinds of showing the sentences printed on the screen. You will use them intuitively if you will need them later and they are quite easy to implement. Until now we have just printed on the screen sentences known as Strings.



Discuss more on the forums >>>

Page number: 5

<<< Previous1 2 3 4 5 6 7 8 9 10 11 12 13 Next >>>


Comments

Brutal on 2013-10-20


Would love to contribute to this project. Seems very easy to understand and gives fast results.

wasi90lk on 2013-10-20


Nice features. This can definitely help us compare graphic cards.

mehdi on 2013-11-17


how can move objects ?
in this program you clear the screen,if there is two thing then this can,t help
if some one know how do that please send me email .
mehdiparizi20@yahoo.com


Only registered members can comment. If you have already registered, you can login here.