p2p.wrox.com 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 4th, 2009, 04:58 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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 05:04 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working With Word Template From ASP.NET and VB.NE Haribabu74 Classic ASP Components 1 November 6th, 2008 05:36 AM
Update the Word template list on an ASP.NET page cJeffreywang ASP.NET 2.0 Basics 0 July 19th, 2007 07:32 PM
Compilation Error with ASP.Net 2.0 & IIS 5.1 gmitchell7 ASP.NET 2.0 Basics 0 April 17th, 2006 05:52 PM
template in asp dot net shinedas ASP.NET 1.0 and 1.1 Basics 0 October 8th, 2005 01:35 AM
ASP.Net:using Radio Button as template in Datagrid mishi ASP.NET 1.1 3 April 10th, 2005 04:41 PM



All times are GMT -4. The time now is 02:03 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc