Click here to Skip to main content
16,005,149 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Network Monitoring Pin
David Crow15-Dec-03 6:56
David Crow15-Dec-03 6:56 
GeneralRe: Network Monitoring Pin
aroraavinash15-Dec-03 13:19
aroraavinash15-Dec-03 13:19 
GeneralRe: Network Monitoring Pin
David Crow16-Dec-03 2:29
David Crow16-Dec-03 2:29 
GeneralRe: Network Monitoring Pin
Chechi15-Dec-03 18:00
Chechi15-Dec-03 18:00 
GeneralRe: Network Monitoring Pin
Tom Wright15-Dec-03 11:38
Tom Wright15-Dec-03 11:38 
Generalbuild errors Pin
pankajdaga14-Dec-03 6:11
pankajdaga14-Dec-03 6:11 
GeneralRe: build errors Pin
Ian Darling14-Dec-03 7:06
Ian Darling14-Dec-03 7:06 
GeneralRe: build errors Pin
Steen Krogsgaard14-Dec-03 22:34
Steen Krogsgaard14-Dec-03 22:34 
Ian Darling wrote:
VC++ (and almost all other C++ compilers) currently can't compile a template where the declaration of a template class is separate from it's implementation. This is addressed through the export template feature in the C++ standard. However, pretty much nobody supports it because it's a freaking pain in the arse to do. For the time being, keep it all in the same file.

Sorry to say, but this is not entirely correct IMHO. The OPs problem is that he didn't use the right syntax as he forgot the template parameter after the class name:

template <class T> Test<T>::Test(T* source)


It's not necessary to define the template at the point of declaration (i.e. in the header file). It's perfectly legal to define the template in a cpp file. However, it's true that the declaration and the definition has to be in the in the same translation unit, and one solution to this is to put the definition in the header along with the declaration. I usually put the definition of template member functions in a .inc (include) file that is included at the end of the .h file, but that's just my personal preference.

What is true is that you cannot export a template - you'll get a LNK2001 error. Since templates are a compile-time object it doesn't make sense to export it anyway, so the C++ standard should be changed to omit the export template feature. What you can do is export instantiations of the template (unless you use VC++ 6.0 which will give you an internal compiler error if you try).

Cheers
Steen.

"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
GeneralRe: build errors Pin
Bo Hunter14-Dec-03 19:55
Bo Hunter14-Dec-03 19:55 
GeneralLinking MFC code with non MFC code Pin
debsbunny714-Dec-03 0:59
debsbunny714-Dec-03 0:59 
GeneralRe: Linking MFC code with non MFC code Pin
Mike Dimmick14-Dec-03 3:41
Mike Dimmick14-Dec-03 3:41 
GeneralRe: Linking MFC code with non MFC code Pin
debsbunny714-Dec-03 4:40
debsbunny714-Dec-03 4:40 
GeneralRe: Linking MFC code with non MFC code Pin
Mike Dimmick14-Dec-03 4:59
Mike Dimmick14-Dec-03 4:59 
GeneralRe: Linking MFC code with non MFC code Pin
debsbunny715-Dec-03 4:18
debsbunny715-Dec-03 4:18 
GeneralSource Safe Automation Question Pin
YaronNir13-Dec-03 21:10
YaronNir13-Dec-03 21:10 
QuestionHow can i hide some exe file? Pin
novachen13-Dec-03 20:17
novachen13-Dec-03 20:17 
AnswerRe: How can i hide some exe file? Pin
Antti Keskinen14-Dec-03 0:58
Antti Keskinen14-Dec-03 0:58 
AnswerRe: How can i hide some exe file? Pin
Mike Dimmick14-Dec-03 3:43
Mike Dimmick14-Dec-03 3:43 
AnswerRe: How can i hide some exe file? Pin
Terry O'Nolley14-Dec-03 12:02
Terry O'Nolley14-Dec-03 12:02 
GeneralTrouble in warp a function in COM dll Pin
novachen13-Dec-03 20:00
novachen13-Dec-03 20:00 
GeneralcontentEditable in div in C++ app no processing Enter Pin
Neville Franks13-Dec-03 17:44
Neville Franks13-Dec-03 17:44 
GeneralRe: contentEditable in div in C++ app no processing Enter Pin
alex.barylski24-Mar-04 23:18
alex.barylski24-Mar-04 23:18 
QuestionCFile Read questioN? Pin
Maverick13-Dec-03 16:36
Maverick13-Dec-03 16:36 
AnswerRe: CFile Read questioN? Pin
Neville Franks13-Dec-03 17:43
Neville Franks13-Dec-03 17:43 
AnswerRe: CFile Read questioN? Pin
bryce14-Dec-03 17:27
bryce14-Dec-03 17:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.