Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2005
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2005 by Ivor Horton; ISBN: 9780764571978
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 4th, 2009, 03:58 PM
Registered User
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default template compilation in .NET

Hi,
Is it not possible to have the method definitions of a template class in a separate src file, instead of defining everything in a single file in .NET?(Because you do not have an example doing this in the book)
If it is posible, why do i get an error C2995 for the following trivial code?
In file test.h
Code:
#ifndef TEST_H
#define TEST_H

template<typename T>
class test
{
public:
	test();
	~test();
	void setV(T i);
private:
	T value;
};
#include "test.cpp"
#endif
and in file test.cpp
Code:
#include"test.h"

template<typename T>
test<T>::test(){}

template<typename T>
test<T>::~test(){}

template<typename T>
void test<T>::setV(T i){value = i;}
Why do I get this? It is obvious that the methods are declared but not defined in the test.h

Thank you
d:\testCPP_akis\tempS\tempS\test.cpp(4) : error C2995: 'test<T>::test(void)' : template function has already been defined
d:\testCPP_akis\tempS\tempS\test.h(8) : see declaration of 'test<T>::test'
d:\testCPP_akis\tempS\tempS\test.cpp(7) : error C2995: 'test<T>::~test(void)' : template function has already been defined
d:\testCPP_akis\tempS\tempS\test.h(9) : see declaration of 'test<T>::~test'
d:\testCPP_akis\tempS\tempS\test.cpp(10) : error C2995: 'void test<T>::setV(T)' : template function has already been defined
d:\testCPP_akis\tempS\tempS\test.h(10) : see declaration of 'test<T>::setV'

Last edited by akmeref; August 4th, 2009 at 04:04 PM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working With Word Template From ASP.NET and VB.NE Haribabu74 Classic ASP Components 2 July 22nd, 2014 05:11 PM
Update the Word template list on an ASP.NET page cJeffreywang ASP.NET 2.0 Basics 0 July 19th, 2007 06:32 PM
Compilation Error with ASP.Net 2.0 & IIS 5.1 gmitchell7 ASP.NET 2.0 Basics 0 April 17th, 2006 04:52 PM
template in asp dot net shinedas ASP.NET 1.0 and 1.1 Basics 0 October 8th, 2005 12:35 AM



All times are GMT -4. The time now is 08:15 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.