![]() |
|
#1
|
|||
|
|||
templated object as member data in a class?Hello, I'm getting compiler errors if I try to move a templated object from my main into a variable holder class. The object is an STL vector, and I'm delcaring it in my main like this:
Code:
and this works fine. However, I'd like to have it as public data in a class. Such as this: Code:
although, for some reason, it doesn't like this. Of course, I guess I'm declaring it wrong or something. The compiler error says "expected ; before < token" on the line where I declare the hits vector. If I change the declaration in the class to this... Code:
it gives another error that says that ISO forbids me to not include a type for the template. Would anyone help me out? |
|
#2
|
||||
|
||||
|
Quote:
At a first glance, I would say you either didn't include the vector header or didn't make the std namespace available (in the file where you declare your class). Please make sure you do this in the file containing the class definition: CPP / C++ / C Code:
If it still doesn't work, please post back and I'll take another look. Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein Last edited by LuciWiz : 03-Aug-2005 at 03:30.
|
|
#3
|
|||
|
|||
|
ah, yes, that was the problem, thank you. Namely, the using namespace std; -- i always take that for granted since it's always in the new file template in pretty much every compiler.
|
Recent GIDBlog
Toyota - 2008 November Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 14:12 |
| [Tutorial] GUI programming with FLTK | dsmith | FLTK Forum | 10 | 03-Oct-2005 16:41 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | C++ Forum | 2 | 19-Dec-2004 07:06 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 16:13 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The