RE: C++ basics part 1 09-14-2013, 12:30 AM
#6
Fair tutorial, however it could prove to be more useful to new programmers if you'd explain things better.
For example,
You neglect to explain what a namespace actually is or what the 'using' keyword actually indicates to the compiler. In addition to this, to access the functions in the 'std' namespace, one does not have to declare 'using namespace std'.
You can access the functions, objects and whatnot simply by doing this:
I just feel as if that is worthy of a small mention, at least.
Also,
You should not have mentioned the string object before getting to the subject of arrays (since a string is basically an array of characters). It would have been a lot better for the new programmers to learn about characters, arrays then arrays of characters before making use of C++'s string class. In addition to that, there are a number of differences in functionality between C-style strings and C++ style strings. These differences are very important for the readers to understand and become aware of.
C-style string:
Making use of the C++ string class:
Also, you probably should have mentioned the range and size of each basic data type. Probably throw in some better descriptions as well...
Just a very simple example of what I think you should have displayed to the newbie programmers:
I'm not going to list all of the basic data types that a beginner should be familiar with, so I'll direct anyone reading this to a couple of useful links:
In conclusion, I found the tutorial was pretty alright. Just required a lot more explanation. Not only that, but by making a basic C++ tutorial you should always assume that your readers are complete beginners unless you specify otherwise.
For example,
Quote:Code:using namespace std;
std is the standard 'namespace' in c++, this is also used in every program so that the basic functions of a program can be performed.
Code:int main() { return 0; }
You neglect to explain what a namespace actually is or what the 'using' keyword actually indicates to the compiler. In addition to this, to access the functions in the 'std' namespace, one does not have to declare 'using namespace std'.
You can access the functions, objects and whatnot simply by doing this:
Code:
std::string
OR
std::cout << "LOL";
OR
int x=0;
std::cin >> x;
etc.I just feel as if that is worthy of a small mention, at least.
Also,
Quote:Just like every programming language, c++ has some basic variables these are:
string - a line of text
int - a whole number
double - a number with decimals
float - an extremly long number with decimals
char - a single charachter, such as 'a' or '!'
You should not have mentioned the string object before getting to the subject of arrays (since a string is basically an array of characters). It would have been a lot better for the new programmers to learn about characters, arrays then arrays of characters before making use of C++'s string class. In addition to that, there are a number of differences in functionality between C-style strings and C++ style strings. These differences are very important for the readers to understand and become aware of.
C-style string:
Code:
char hello[6]={'h', 'e', 'l', 'l', 'o', '\0'};
OR
char hello[6]="hello";Making use of the C++ string class:
Code:
In order to use C++ style strings, one must include this class (it can be found in the standard C++ library):
#include <string>
Upon doing that, you can declare C++ style strings using the keyword "string":
string hello="hello";Also, you probably should have mentioned the range and size of each basic data type. Probably throw in some better descriptions as well...
Just a very simple example of what I think you should have displayed to the newbie programmers:
Quote:char - This data type can hold a single character of size 1 byte.
int - This data type can hold an integer of size 4 bytes. An integer stored in a variable of this data type can be as small as -2147483648 to as large as 2147483647.
bool - This data type can hold a boolean value of size 1 byte. A boolean is a logical data type which can only contain two values: true or false.
... etc.
I'm not going to list all of the basic data types that a beginner should be familiar with, so I'll direct anyone reading this to a couple of useful links:
Code:
http://www.tutorialspoint.com/cplusplus/cpp_data_types.htm
http://www.cplusplus.com/doc/tutorial/variables/In conclusion, I found the tutorial was pretty alright. Just required a lot more explanation. Not only that, but by making a basic C++ tutorial you should always assume that your readers are complete beginners unless you specify otherwise.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)