Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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..





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.