classes and objects

This is a discussion on classes and objects within the C++ Programming forums, part of the General Programming Boards category; Well, to be honest I haven't used dev-c++ in a long time myself, but there are many people here who ...

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338
    Well, to be honest I haven't used dev-c++ in a long time myself, but there are many people here who have who will hopefully chime in. I think you have to add the two cpp files to a project, then build the project.

  2. #17
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,765
    I haven't really used Dev-c++, but VS Express will handle all these details for you. It might be good for you since you don't seem to understand the process.
    What you typically do is just add all your .cpp files to your project and then just build and everything is done for you.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    Registered User
    Join Date
    Apr 2008
    Posts
    44
    I believe I did it... Well I thought so yesterday too, but I was wrong...

  4. #19
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    the code in post 3 has the correct division of definition and implementation files, just link them properly.
    Last edited by m37h0d; 05-06-2008 at 08:25 AM.

  5. #20
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    Quote Originally Posted by cpjust View Post
    No, you declare them in the header.
    I noticed you use string a lot in the header & .cpp files. Since you didn't put using namespace std; in the header (and you should NEVER EVER do that anyways) the compiler should be saying it doesn't know what string is.
    Change string to std::string in all places, since it's in the std namespace.

    BTW, what compiler are you using?
    If it's VC++, make sure all files are part of the Project.
    If you're using a makefile, make sure you're compiling both .cpp files and linking them both into the final executable.
    On what arguments one should never use ' using namespace std; ' ? One argument to use it is that for VisualStudio6, and yes old compilers are still in use, some stuff had been declared in the global namespace.
    So with explicitely specifying the namespace with the scope operator, this can cause errors.

  6. #21
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338
    I've only seen that in regards to C library names (e.g. rand(), strcmp, printf, etc) on VC++ 6.0. Explicitly stating the namespace works on that compiler on C++ library names (e.g. string, cout, vector, etc).

    Besides, you really shouldn't worry about appeasing VC++ 6.0 in your current code. That compiler is too old to pay attention to.

    My rule on using namespace std is to never use it and always use std::. The general rule is that you should never put a using namespace directive before other code that is included. That means don't put it in a header, because once the compiler sees it in your header it will do it for all source files that include that header and all other header files included after that header. Also you shouldn't put it before other headers in a source file for the same reason. I prefer not to have to remember all that and just use std:: everywhere.

  7. #22
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by MarkZWEERS View Post
    On what arguments one should never use ' using namespace std; ' ? One argument to use it is that for VisualStudio6, and yes old compilers are still in use, some stuff had been declared in the global namespace.
    So with explicitely specifying the namespace with the scope operator, this can cause errors.
    Did you click on that link and read Chapter 59?

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

Similar Threads

  1. Classes & Objects [c++]
    By salmansalman in forum C++ Programming
    Replies: 6
    Last Post: 05-14-2008, 08:02 AM
  2. Overloading Array Objects for use with Classes
    By ibleedart in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2007, 06:48 PM
  3. static classes vs objects
    By earnshaw in forum C# Programming
    Replies: 5
    Last Post: 02-08-2006, 02:19 PM
  4. Accessing/working with member objects of parent classes
    By ChadJohnson in forum C++ Programming
    Replies: 4
    Last Post: 03-31-2005, 10:01 PM
  5. Trouble Understanding Classes and Objects. Please Help.
    By Jeffcubed in forum C++ Programming
    Replies: 4
    Last Post: 12-06-2002, 01:23 PM

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