LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-26-2006, 06:18 PM   #1
allomeen
Member
 
Registered: Dec 2005
Posts: 83

Rep: Reputation: 15
overloading a template


Hello,

Is it possible to overload a template?

I'm trying to built an Object that is similar to Visual Basic Collection. So i'm trying to overload my template like this:

template<typename Key, typename Value>
class collection
{
...
}

template<typename Value>
class collection
{
...
}

Is this possible??

Alaa
 
Old 01-26-2006, 06:59 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Sorry but I don't know VB, however you could put your Key typename second and give it a default value, if that was what you wanted to do...

Code:
template<typename Value, typename Key = int>
class collection
{
...
}
graeme
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Template class with a template member... Nicholas Bishop Programming 3 02-21-2005 08:27 PM
Error with << overloading moses101 Programming 1 06-17-2004 03:31 PM
c++ [] operator overloading exodist Programming 12 04-17-2004 03:06 PM
<< overloading lazyboy0001 Programming 2 04-10-2004 07:25 PM
C++ overloading extraction operator petercool Programming 5 09-06-2003 06:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration