• Lucid Dreaming - Dream Views




    Results 1 to 25 of 165

    Threaded View

    1. #27
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Hmm... how to describe how namespaces work That's not important right now (and an odd concept before learning classes,) you can use cout simply and add a using namespace std at the top of the program.


      Basically, there are multiple couts and the compiler has to know which one to use. std:: tells it to use the std one, you did that in your program by defining that the entire program uses std. Here's a little demonstration of namespaces.

      Code:
      #include <iostream>
      using namespace std;
      
      namespace Integer{
        int var = 5;
      }
      
      namespace Decimal{
        double var = 3.1416;
      }
      
      int main () {
        cout << Integer::var << endl;
        cout << Decimal::var << endl;
        return 0;
      }
      Weird, I know, but very useful for more advanced programming, for now you can forget what I just said
      Last edited by ninja9578; 01-11-2010 at 02:08 AM.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •