how do i compile a program that deals w/classes?

This is a discussion on how do i compile a program that deals w/classes? within the C++ Programming forums, part of the General Programming Boards category; I'm thinking that the reason why I keep getting error messages during compile time is because I don't know how ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    23

    how do i compile a program that deals w/classes?

    I'm thinking that the reason why I keep getting error messages during compile time is because I don't know how to compile programs that deal with classes. Let's say filename.h is where I create the class, filename.cpp is the member functions definitions, and filename.cc is the main program; how do I compile this. Normally I compile programs by writing CC filename.cc, but since this program deals with classes I don't know how to compile it.

  2. #2
    Unregistered
    Guest
    You have to call the linker.

  3. #3
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    .
    Last edited by Troll_King; 12-01-2001 at 05:54 AM.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    Then be sure to include Myclass.h in Main.cpp using the preprocessor direction #include "Myclass.h", to use troll_king's example.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Yes, make sure the extension is .CPP or the compiler will most likely think you are only compiling a C program. It will spit out all kinds of ugly errors. Classes are not allowed in C so the compiler is not expecting to encounter any. I had the same problem when I started using classes.

  6. #6
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    as another cautionary note... watch out for unresolved externals... if you have your class in a seperate object file, the source object file that implements that class must have knowledge of the declaration... i also had problems with this when i first dealt with seperately compiled object files...
    hasafraggin shizigishin oppashigger...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 08:51 PM
  2. Compile Public Domain Pocket PC C Program
    By m1l in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 07-20-2007, 05:02 AM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  4. new to C--can't get program to compile
    By samerune in forum C Programming
    Replies: 12
    Last Post: 04-02-2007, 10:44 AM
  5. Replies: 1
    Last Post: 02-13-2003, 08:08 AM

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