Class Issues - External File

This is a discussion on Class Issues - External File within the C++ Programming forums, part of the General Programming Boards category; i everyone, I have a Class in an external file, and it seems no matter where i look on the ...

  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,344
    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,344
    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, 11: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, 01: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, 05:14 AM
  5. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM

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