E
Eric Lilja
Hello, I recently saw code like this:
$ cat t.h
namespace nc{
template<typename T>
class Base {
T hello;
protected:
int test1;
};
template<typename T>
class Next: public Base<T>{
int test();
};
};
#include "t.tmpl"
$ cat t.tmpltemplate<typename T>
int nc::Next<T>::test(){
return test1;
}
I couldn't even get the code to compile until I'd changed return test1;
toreturn Base<T>test1;"t.tmpl" looks like a renamed source (.cpp) file and
it's used to work around the fact that the compilerlacks the export keyword
but the author still wantsto hide the implementation details. I
immediatelythought this was ugly indeed, was I right? If so, why?/ Eric
$ cat t.h
namespace nc{
template<typename T>
class Base {
T hello;
protected:
int test1;
};
template<typename T>
class Next: public Base<T>{
int test();
};
};
#include "t.tmpl"
$ cat t.tmpltemplate<typename T>
int nc::Next<T>::test(){
return test1;
}
I couldn't even get the code to compile until I'd changed return test1;
toreturn Base<T>test1;"t.tmpl" looks like a renamed source (.cpp) file and
it's used to work around the fact that the compilerlacks the export keyword
but the author still wantsto hide the implementation details. I
immediatelythought this was ugly indeed, was I right? If so, why?/ Eric