Problem with class header please help

This is a discussion on Problem with class header please help within the C++ Programming forums, part of the General Programming Boards category; Hello i have a problem.... i am trying to split a cpp file, where i have the class declaration, class ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    Problem with class header please help

    Hello
    i have a problem.... i am trying to split a cpp file, where i have the class declaration, class implementation and main, into three separate files.
    So i have created dataset.h with the following code:
    Code:
    #if !defined(DATASET_H)
    #define DATASET_H
    
    class DataSet
    {
    public: .....
    private......
    }
    #endif
    
    The file dataset.cpp with:
    #include "dataset.h"
    
    DataSet::DataSet
    {
    }
    .... and  the other member functions declarations.
    and the file main.cpp with

    #include "dataset.h"
    and the main function, where i call some public member functions of class DataSet. When i compile, it says:
    Linker error: undefined symbol dataset::function1 in module main
    and the same for all the functions i try to call.

    What did i do wrong? The program worked perfectly before trying to split it.

    Thank you very much.
    Last edited by Salem; 08-09-2006 at 11:52 AM. Reason: code tags - learn to use them!

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Did you implement DataSet::function1 in dataset.cpp?

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    your project linker must link both main.obj and dataset.obj -- it is probably not linking with dataset.obj (might be .o extension if you are using Dev-C++ or gnu compiler).

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    2
    For Tonto: yes, i have declared all the functions in Dataset.cpp
    For Ancient Dragon: I use Borland C++ compiler v3.1. Does this help?

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,765
    > I use Borland C++ compiler v3.1. Does this help?
    Well it's not helping you by using some old fossil.
    See other recent posts which use old compilers, and where to get something more modern.

    Essentially, you need
    bcc main.cpp Dataset.cpp

    How you do that in your project file for your IDE is for you to figure out, but you're not compiling all your source at the moment.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM
  4. Replies: 3
    Last Post: 12-03-2001, 01:45 PM

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