Thread: Class Issues - External File

  1. #1
    Registered User
    Join Date
    May 2007
    Location
    Melb Australia
    Posts
    7

    Unhappy Class Issues - External File

    i everyone,

    I have a Class in an external file, and it seems no matter where i look on the net, I can't seem to find any info on how to get the class into the file with the main function, so i can create objects of said class...

    Now I'm sure this has got to be easy as hell to figure out, but it just isnt happening for me, the compiltion errors i get are thus:

    Code:
    OS.cpp:21: `Thread' undeclared (first use this function)
    OS.cpp:21: (Each undeclared identifier is reported only once for each function
       it appears in.)
    OS.cpp:21: template argument 1 is invalid
    OS.cpp:21: template argument 2 is invalid
    OS.cpp:21: template argument 3 is invalid
    OS.cpp:21: ISO C++ forbids declaration of `pQueue' with no type
    and line 21 is:

    Code:
    priority_queue<Thread> pQueue;
    where thread is the name of the class that is messing me about.

    If anyone is willing to help me out with this, it would be most appreciated. Thanks

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Normally, Thread would be declared in a header file (e.g. Thread.h) and you would include that header in the OS.cpp file (e.g. #include "Thread.h").

    Did you include the header that defines the Thread class?

  3. #3
    Registered User
    Join Date
    May 2007
    Location
    Melb Australia
    Posts
    7
    look, I've just scrapped it and put the class in the same file as my main file...

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    That's one solution, although you're going to have to figure this out at some point if you keep using C++. It is probably not even a difficult problem either.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  5. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM