Tuesday, July 14, 2009

C++ problem ,, Help pls?

Hey i saw buzz's c++ tutorials ...


In those tuts in the first program they've written a program like this [ theyre using Visual Studio.net ]








#include%26lt;iostream.h%26gt;


using std::cout;


{


cout%26lt;%26lt;"Hello";


}





And in the tutorials when they run the program without the


" using std::cout; "


command, they arent able to run it


whereas i dont need to type in that command to run the program in Turbo C++ or Visual studio..


So can any one tell me that what is the command for ? And is it only used in visual studio.net or what ???

C++ problem ,, Help pls?
Well, I am not a C++ programmer, but I have a feeling this may be because - as in VB or C# - there are some libraries included in some part of your IDE that are not included in the one being refrenced in the tutorial.





For example : in VBA (the code behind MS Access), there is a place where you can select "refereces" to other libraries, like Outlook, Adobe, etc. If you check one of the references in the box displayed, you can directly access objects in that library in the code. If not, you can't.





Chances are that there is a similar functionality in C++ (I know there is in VS.NET) and you have the library for 'std:cout' selected; the people in the tutorial don't, so they have to call it explicitly from their code, while yours is included automatically because of different compiler options.





This would be my guess, having experienced similar things in different languages.
Reply:Whatever you are using to program in C++ may already be loading and including the command under the covers... that's why you don't need to add it. In the tutorial, they may be using something a little more primitive, so they have to indicate this.








using std::cout; is used to tell the compiler "Use this namespace "std", because I don't want to type std:: before every cout".





It's just an indicator, to make things simpler for you (the developer), so that you don't have to type std::cout everytime... instead you just do cout.

gladiolus

No comments:

Post a Comment