User forums > Using Code::Blocks
Template compilation with v1rc2
jmeuf:
Hi,
I'm trying to compile the following code:
--- Code: ---#include <vector>
template <class T>
class ListModule
{
public:
ListModule();
~ListModule();
protected:
private:
vector<T> _List;
vector<T>::iterator _It; // << Error is here
};
--- End code ---
and get a message at compilation: Error : expected ';' before "_It"
I compile under C::B v1rc2 using the gnu compilers.
Is it due to the compiler (did you also get such an error) or is it my mistake (I'm not so familiar with templates...)?
Thanks.
TDragon:
First, this question is compiler-related rather than Code::Blocks related, so it would be appropriate to ask this question at a forum for general C++ programming help rather than here.
Second, the exact code you posted will raise a compiler error at the first declaration of vector rather than the second, because vector hasn't been qualified with the std namespace.
So make sure that the code you post at whichever general programming help forum you choose actually does exhibit whatever error you're getting.
Cheers,
JohnE / TDM
P.S. -- Even if the question were C::B-related, you'd only be told to download a nightly build. Code::Blocks has come a long way since RC2.
jmeuf:
Ok thanks for your advice. I will test that on a nightly.
TDragon:
--- Quote from: jmeuf on March 29, 2007, 04:38:29 pm ---Ok thanks for your advice. I will test that on a nightly.
--- End quote ---
In case you didn't understand me the first time:
Your problem is compiler-related, not Code::Blocks-related. Code::Blocks has nothing to do with your code causing errors when compiled. Whether code can compile is determined by (1) the code's correctness (2) according to the compiler being used, and upgrading C::B will change neither.
jmeuf:
As I could see it in the content of nightly build distributions, the Mingw compiler also evolves, and not only the GUI. Am I correct?
Concerning the <vector> declaration, the std is already resolved in my code, and the first declaration (the vector, not the iterator) compiles properly.
Navigation
[0] Message Index
[#] Next page
Go to full version