-
July 7th, 2009, 12:51 PM
#1
C++ template question
Hello all, I am new to using templates and run into a problem:
I have a file foo.h:
#ifndef FOO_H_
#define FOO_H_
class foo{
public:
foo();
template <unsigned int ID>
int doSomething();
virtual ~foo();
};
#endif /* FOO_H_ */
and a foo.cpp:
#include "foo.h"
foo::foo() {
}
template <unsigned int ID>
int foo:oSomething(){
....
}
foo::~foo() {
}
and in my main.cpp I want to do something like:
#include "foo.h"
int main(int argc, char *argv[]){
foo *bar = new foo();
foo->doSomething<2u>();
return 0;
}
The problem is that whenever i try this i get undefined reference to `int foo:oSomething<2u>()
I have tried a number of variations to call the template (and tbh I am not even sure what I want to is possible) but no success.
Any Help would be greatly appreciated. Thank you.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|