c++ doubt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aditivarma
    New Member
    • Sep 2008
    • 3

    c++ doubt

    what is the diff between these two.I am getting errors if i use second one in place of 1st

    1) #include<iostre am>

    using namespace std;

    2) #include<iostre am.h>
  • myusernotyours
    New Member
    • Nov 2007
    • 188

    #2
    Originally posted by aditivarma
    what is the diff between these two.I am getting errors if i use second one in place of 1st

    1) #include<iostre am>

    using namespace std;

    2) #include<iostre am.h>

    The first one is a the new style that is defined by Standard C++. The second one actually specifies the file that the preprocessor will include thats why it even has a .h extension. Am not sure how the first is actually implemented. Both styles should work unless they are quirks with the compiler you are using, probably some missing setting or something... The namespace is also a new C++ feature. It just specifies a declarative region in which we can place program objects which makes organising large programs easier.

    It's advisable to just stick to the first one though. That's what many C++ compilers understand.

    So what kind of errors are you getting?

    Regards,

    Alex,

    Comment

    • vinayvaka
      New Member
      • Nov 2007
      • 13

      #3
      namespace is the user space where we can define our own data types.
      main use of namespace is to reduce the configs of global. let me explain in detail when we try to declare the global variable, if the same name already exits then we gets the problem, so to avoid this confilgs c++ allowing users to create our own namespace where we can declare our global variables and we can include this namespace in the program.
      using namespace vinay;
      hear vinay is the namespace in this i have created my global variables; and also we can define printf and scanf defnitions also.

      Comment

      Working...