Opening a file from the a console program

This is a discussion on Opening a file from the a console program within the C++ Programming forums, part of the General Programming Boards category; could someone explain 'using namespace std;' thanks...

  1. #16
    ima n00b, ok? orion-'s Avatar
    Join Date
    Aug 2005
    Location
    alberta, canada
    Posts
    55
    could someone explain 'using namespace std;' thanks

  2. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    It's part of the new header, <iostream>. A namespace is an area where you can have unique names. It's so names don't clash between files. using namespace std imports the entire std namespace so you can use everything in it.

    Actually, you should use code like this
    Code:
    using std::cout;
    using std::cin;
    using std::endl;
    // ...
    to import only the things you're going to use. That way there's even less chance of name clashes, and you don't "polute" the global namespace with functions and classes from the std namespace.

    Most people just use "using namespace std", because it's shorter. If you do this, you can't use names that belong in std.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #18
    Aspiring "Software Guy"
    Join Date
    Aug 2005
    Posts
    46
    I dont know nething abt this, but how come the code i posted doesnt give any errors in turbo c++? How much difference is there between the 2 ? Which is better? Are Borland complilers always different? Which one shud i stick to?

    Thanx,
    pritin.cool@gmail.com

  4. #19
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Turbo C++ is just old. Pre-standard.
    Kurt

  5. #20
    Aspiring "Software Guy"
    Join Date
    Aug 2005
    Posts
    46
    So is there always a difference between Borland and Dev cpp or are the later versions of Borland the same as Bloodshed ?

  6. #21
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by pritin
    So is there always a difference between Borland and Dev cpp or are the later versions of Borland the same as Bloodshed ?
    Dev-Cpp is not a compiler. It's just an IDE. It usually comes with some version of the GNU-compiler whitch is pretty close to the current C++ standard. I don't have any experience with the new borland compilers but I think they implement the standard quite well. Turbo C++ is really old.
    Kurt

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-22-2008, 12:19 AM
  2. Opening a .html file from the console
    By Verdagon in forum C++ Programming
    Replies: 9
    Last Post: 08-02-2005, 06:05 AM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  4. Opening a file in a different program...
    By gcn_zelda in forum Windows Programming
    Replies: 2
    Last Post: 09-07-2003, 11:44 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21