GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Oct-2006, 11:53
qboy qboy is offline
New Member
 
Join Date: Sep 2006
Posts: 23
qboy has a little shameless behaviour in the past

template <class Data> problem, more than one data type


I'm trying to make a generalized class which can take any type of data type. I know how to input the data type in the main method if I only have one type of data type in that object. But what if I have more than one data type? Like say I have a Keyword object. Keyword has two data type in each.

CPP / C++ / C Code:
template <class Data>
Keyword<Data>::Keyword(string s, vector<int>);

Now... when I want to create a Keyword object in the main method how would I do that? It asks me for the data type but I have two data types, how would I declare that? Thanks.
Last edited by LuciWiz : 13-Oct-2006 at 13:40. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 13-Oct-2006, 17:08
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: template <class Data> problem, more than one data type


Quote:
Keyword has two data type in each.
Huh? Yes, there are two parameters to the Keyword constructor you gave, but that doesn't matter.

CPP / C++ / C Code:
string my_str = "stuff";
vector<int> intvec;
intvec.push_back(453);
intvec.push_back(2);
Keyword<float> floatKey(my_str, intvec);
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
error template with C linkage MichaelS-R C++ Forum 6 17-May-2006 12:09
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12
Strange C++ code memory leakage problem gaoanyu C++ Forum 7 04-Nov-2005 09:09
C++ PhoneBook marita C++ Forum 46 12-Jun-2005 13:10
[CONTEST?]Data Structure Test dsmith C Programming Language 2 06-Jun-2004 16:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:20.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.