![]() |
|
#1
|
|||
|
|||
template comiling problems - need expert debugger!hi there. i am on a UNIX system and am writing a template code called Array.h. it is called by a Test2.C file which does nothing more than declare a T object of type int. Array<int>.
i am getting all kinds of compile errors. have been over it and over it for about 8 hours now. can anyone help me here. i know there is something wrong with my non-member functions and i know there is something wrong with my init method that constructs my T's. this is what i am getting from the compiler when i run Test2.C Array.h:71: syntax error before `&' token Array.h:71: `ostream' was not declared in this scope Array.h:71: `os' was not declared in this scope Array.h:71: syntax error before `<' token Array.h:71: ISO C++ forbids declaration of `operator<<' with no type Array.h:71: `int& operator<<(...)' must have an argument of class or enumerated type Array.h:71: `int& operator<<(...)' must take exactly two arguments Array.h: In member function `void Array<T>::init(const T*, int)': Array.h:349: syntax error before `;' token Array.h: At global scope: Array.h:366: syntax error before `>' token Array.h:370: `b' was not declared in this scope Array.h:370: syntax error before `;' token Array.h:370: syntax error before `++' token if anyone wanted to help me figure out what is going on with this mess that would be great. this is only PART A of what i need to be doing (ha ha). and this is my Array.h of template T CPP / C++ / C Code:
CPP / C++ / C Code:
Last edited by LuciWiz : 29-Jan-2005 at 16:29.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#2
|
||||
|
||||
|
I will try to point you in the right direction... Be warned that I am bored, so I hope you are really interested in learning here.
Your first 7 compile-time errors occur at line 71. Lets consider each. Quote:
In this case, this message indicates that the compiler did not recognize a symbol in line 71 that precedes an occurrence of the '&' operator. That operator occurs twice in the line, and both times is immediately preceded by the symbol 'ostream'. But before we draw a conclusion, let's look at the next message. Quote:
CPP / C++ / C Code:
CPP / C++ / C Code:
Now, if the compiler did not understand the typename 'ostream', you can guess what the next message means. Quote:
Next, on line 349, pay close attention to the right side of the assignment statement. What is wrong with this picture (remember, T is a typename)? CPP / C++ / C Code:
On line 366, again look carefully at what you've typed. CPP / C++ / C Code:
After identifying and fixing these errors in your code, see if you can continue to work through other problems. Remember, the messages the compiler spits out usually have more than enough information to guide you, if you learn how to read them. Good luck. :-) |
Recent GIDBlog
Toyota - 2008 September Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | C++ Forum | 2 | 19-Dec-2004 06:06 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The