Skip to main content
gamedev.net
🔒 Locked

function templates

Started by Stezka 2 replies 500+ views
Original Post
Stezka
Stezka
Hi, i am new to templates and i cant get my first function template working. Here is the code:
#include <iostream.h>

class a {
public:	
	template <class T> void function(T arg);	
};

template <class T> void a::function(T arg) {
	cout << arg;
}

int main() {

	a A;
	A.function(5);

return 0;
}
I guess that the error is in declaration of function() but i dont know what is the correct way. Compiler tells me that it failed to specialize function template 'void __thiscall a::function(T)' [edited by - stezka on July 20, 2003 12:07:05 PM]
Null and Void
Null and Void
Your compiler is broken.

By the way, standard C++ headers no longer have a ".h" suffix, and their contents are placed in the std namespace.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.