Thread: Can't include Classes(very strange)

  1. #1
    Registered User
    Join Date
    Jan 2002

    Can't include Classes(very strange)

    I have a very strange problem. With my classes client and password I can include them separately by calling the cpp file, ie. (#include "client.cpp", and #include "password.cpp"). I have tested them separately.

    If I call the header I don't get a compile error but it doesn't recognize the class and I can't declare objects.

    If I include them together I get the error:
    [C++ Error] CLIENT.CPP(5): E2090 Qualifier 'client' is not a class or namespace name.

    As I said if I use them separately they are fine.

    Can anybody help? I am using Borland C++ Builder 5


  2. #2
    Registered User
    Join Date
    Aug 2001

    including classes

    You should not be including .cpp files...
    include the .h files....

    You don't have the h files? Well... create them...

    To use multiple files you must have .h files and .cpp files

    The h files is for all declarations that the cpp will need. The cpp will contain all the definitions of the functions. Any other files requiring use of these files require that you include the .h files not the cpp.

    To further beat a horse in the bush...ahhem.. to death I mean...
    //some.h file
    #ifndef SOME_H
    #define SOME_H

    int add(a, b);

    //some.cpp file


    int add(a, b){ return a + b; }

    #include <iostream.h>
    #include "some.h"

    void main( void )
    cout << "Result of 2 + 2 " << add(2, 2) << endl;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use this part of dirent.h
    By kermit in forum Linux Programming
    Replies: 2
    Last Post: 01-31-2009, 08:51 AM
  2. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM
  3. include problem
    By Strait in forum C++ Programming
    Replies: 4
    Last Post: 01-31-2005, 04:01 PM
  4. to #include or not to #include
    By krygen in forum C++ Programming
    Replies: 9
    Last Post: 12-25-2004, 12:06 AM
  5. Dialog Will not appear?
    By curlious in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2003, 10:32 AM