Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. very basic C++ question

very basic C++ question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Binayak
    wrote on last edited by
    #1

    I have a very primitive question on C++. If I want include a library I use #include say, #include , iostream header file all I/O functions are declared. But Including a Standard C++ header does not introduce any library names into the current namespace. For that we have to use using namespace std; What does this mean? Does it mean in namespace std all the functions in standard library files are defined and that's why we need that?

    T T 2 Replies Last reply
    0
    • B Binayak

      I have a very primitive question on C++. If I want include a library I use #include say, #include , iostream header file all I/O functions are declared. But Including a Standard C++ header does not introduce any library names into the current namespace. For that we have to use using namespace std; What does this mean? Does it mean in namespace std all the functions in standard library files are defined and that's why we need that?

      T Offline
      T Offline
      Taka Muraoka
      wrote on last edited by
      #2

      Binayak wrote: using namespace std; What does this mean? Does it mean in namespace std all the functions in standard library files are defined and that's why we need that? Yes. Having the using statement means that you don't have to qualify each individual std name e.g. std::cout << "Hello world" << std::endl


      Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 1.2.1 [^]: A free RSS reader with support for Code Project.

      1 Reply Last reply
      0
      • B Binayak

        I have a very primitive question on C++. If I want include a library I use #include say, #include , iostream header file all I/O functions are declared. But Including a Standard C++ header does not introduce any library names into the current namespace. For that we have to use using namespace std; What does this mean? Does it mean in namespace std all the functions in standard library files are defined and that's why we need that?

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        hi 'binayak', so, to help you, i would say that the C++ standard includes some classes and functions into the std namespace. In fact, be careful to the diference between the folowing directives :

        // automatically include functions into std::
        #include <iostream>
        // dosn't include functions into std::
        #include <iostream.h>

        so, if you use std:: and you don't want to call it each time you want a function defined inside (for example cout << "Hello world !" instead of std::cout << "Hello world !") you'd prefer the command line

        using namespace std;

        Clearly, it tells to the compiler that it will have to look inside the std:: to find the called function. you could also do this if you don't want all the standard namespace to be used implicitly :

        #include <iostream>

        void main (void) {
        using std::cout; // I'm not sure about the syntax, but i know that is possible
        cout << "Hello world !";
        }

        hope that's more clear now ;) TOXCCT alias Nicolas C.

        R 1 Reply Last reply
        0
        • T toxcct

          hi 'binayak', so, to help you, i would say that the C++ standard includes some classes and functions into the std namespace. In fact, be careful to the diference between the folowing directives :

          // automatically include functions into std::
          #include <iostream>
          // dosn't include functions into std::
          #include <iostream.h>

          so, if you use std:: and you don't want to call it each time you want a function defined inside (for example cout << "Hello world !" instead of std::cout << "Hello world !") you'd prefer the command line

          using namespace std;

          Clearly, it tells to the compiler that it will have to look inside the std:: to find the called function. you could also do this if you don't want all the standard namespace to be used implicitly :

          #include <iostream>

          void main (void) {
          using std::cout; // I'm not sure about the syntax, but i know that is possible
          cout << "Hello world !";
          }

          hope that's more clear now ;) TOXCCT alias Nicolas C.

          R Offline
          R Offline
          Robert A T Kaldy
          wrote on last edited by
          #4

          so, to help you, i would say that the C++ standard includes some classes and functions into the std namespace. In fact, be careful to the diference between the folowing directives : No. The iostream.h library is only the Microsoft fake of STL iostream and now is obsolete. so, if you use std:: and you don't want to call it each time you want a function defined inside (for example printf("Hello world !") instead of std::printf("Hello world !")) you'd prefer the command line printf is a function from stdio.h, not iostream. Robert-Antonio "Love without sex is like a fish without antlers"

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups