« first day (103 days earlier)      last day (2749 days later) » 

5:12 AM
#include <cstdio>
#include <vector>

template<typename T>
class aaa
{
public:
typedef std::vector<T> obj_t;
private:
static obj_t bb;
static std::vector<obj_t*> cc;
public:
static void op()
{
printf ( "hello op!\n" );
}
};

template<typename T>
aaa<T>::obj_t aaa<T>::bb;

template<typename T>
std::vector<aaa<T>::obj_t> aaa<T>::cc;

int main()
{
aaa<int>::op();
}
what is the right way to write a out-class declaration of a template class cause I keep having compilation error here
thank you
#include <cstdio>
#include <vector>

template<typename T>
class aaa
{
public:
typedef std::vector<T> obj_t;
private:
static obj_t bb;
static std::vector<obj_t*> cc;
public:
static void op()
{
printf ( "hello op!\n" );
}
};

template<typename T>
aaa<T>::obj_t aaa<T>::bb;

template<typename T>
std::vector<(aaa<T>::obj_t)*> aaa<T>::cc;

int main()
{
aaa<int>::op();
}
What is the right way to write a out-class declaration of a template class? cause I keep having compilation error here..
Thank you.
 
5:28 AM
@Thiner Not in chat, or on pastebin instead, firstly ;)
 
5 messages moved from Lounge<C++>
 
@Thiner Your mistake is on line 20 (the compiler tells you exactly what the problem is), and line 23 appears to have an error as well
 
5:54 AM
so how can I correct it ..?
 
There is one main mistake: you've neglected to use typename when it is required in lines with more than one template parameter (T). It resolves the problem of dependent and non-dependent names
 
?? I did not know what you mean.. So can you show me the right way to write this?
 
This webpage explains the typename keyword. The language assumes any templates you use are objects, even when it's clear that you mean a variable type. So you need typename aaa<T>::obj_t aaa<T>::bb;
The other one occurs when you say std::vector<(aaa<T>::obj_t)*>. The compiler doesn't know that aaa<t> is a type declaration, so you need to declare it using typename
 
6:11 AM
thank you!
 
 
10 hours later…
3:58 PM
and we're back
 
 
4 hours later…
8:12 PM
how do you sqlinject with addslashes if the encoding is latin1 and not gbk?
 
8:27 PM
1 message moved from Lounge<C++>
 

« first day (103 days earlier)      last day (2749 days later) »