Hi, i'm trying to learn c++ reading an english guide, but since english isn't my language and in mine there isn't a good c++ documentation i'm having some doubt... here my doubt:
1)what is the difference between std and the standard library?
2)the instruction "return" must return an integer or can return 1.2 for example?
3)What is a type?
4)what is a namespace?
5)Why four cout is used "<<" and for cin ">>" ? shouldn't be the same operand?
6)What is for the operator "::" and why for use cout i must use "std::cout" instead of simply "cout" ?
7)In the guide i haven't understood if the operators << and >> give more importance at the left or right term, could you explain that ?
what is your mother language?
If it is chinese, then I could recommend you some text books
1 : std is a namespace, standard library wrapped by the namespace std
2 : depent on your return type
3 : sorry I don't know the clear definition of it but int, double , float, even a self define class could be a type
4 : just a method to discern different variables of different scopes
5 : because it would make it reable(it could be overloaded as "<<" or ">>")
6 : "::" is super resolution scope, a method to call the specific namespace
you should use "std::cout" instead of "cout" because "cout" is defined in
the namespace std
7 : both of them are just operator, you could overload them by the way you like
but it is recommend to overload them as their original purpose
(you would not like to overload "*" as "+", right?)
The above description is good enough to start with, I just have one different opinion at 5:
5) Cout is of the type std::ostream and cin is of the type std::istream. To maintain functionality for them combined (general streams of the type std::iostream or std::fstream) they are put in different operators. The arrows represent the data flow in this context:
1 2
STREAM FLOW DATA
cout << "bla";
Would mean that you are sending data to a stream (which is logical, since you print "bla").
1 2
STREAM FLOW DATA
cin >> a;
Would mean that the data goes from cin to a, which is logical, since you input data to a.
Try to view some videos about c++ programming, theres a lot of tutorials about it. Try you youtube.com or other videos related website. It's hard to learn when you can only see text, its nice to have demonstrations. If you have problem try to feedback me at my blog: http://codewall.blogspot.com
If you want, I will create a step by step tutorial for you. I'm a teacher in programming. I want to help those who are needed.
thecodewall, i'm not good to read english, think you at listen english!
if i write "using namespace std" can i just write "cout << "Hello!" " instead of "std::cout << "Hello!" " ?
so i need only that 3 words to don't write std:: ?
the "::" need to call somewhat from the standard library?
is "::" only need for standar library, what call in that line of code? cout << "Maximum value for int: " << numeric_limits<int>::max() << endl;
"cout is of the type std::iostream" basically mean that cout call the output stream function from the standard library?
is the standard library written in C++? for exampe, how is it possible write in C++ iostream?
hey tell us what is your mother language.. maybe someone speaking your language will be able to help you then... ( even i could be speaking your mother language)