473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Class templates

if I have this template declaration:
__________________________________________________ ______________________
template<class ItemType>
class SortedList
{
private:
int length;
ItemType values[MAX_ITEMS];
int currentPos;
public:
SortedList( ); // default constructor: lenght=0,
currentPos=-1

void MakeEmpty(); // let length=0
void InsertItem(ifstream inFile,ItemType x); // insert
x
into the list
void DeleteItem(ItemType x); // delete x from the list
bool IsFull( ); // test if the list is full
int LengthIs( ); // return length
void RetrieveItem(ItemType &x, bool &found); //
retrieve
x from the list, the
// boolean result is stored in found
void ResetList( ); // currentPos=-1
void GetNextItem(ItemType &x); // get the next element
from the list with
// respect to the currentPos
};
---------------------------------------------------------------------------*------------------------------------------

The InsertITem function declared as follows:
template <class ItemType>
void SortedList<ItemType>::InsertItem(ifstream inFile,ItemType x)
{
........etc.
if i call this function from main, it gives an error that x is not
defined and if I include
ItemType x;
in main I get the error `ItemType' does not name a type .
I need to populate 2 lists inputted with data from two file. One
consists on integers and the other of floats. How do I do this using
the above class template?

Mar 28 '07 #1
1 1688
* zf*****@umd.umich.edu:
[repeat of earlier posting]
Why don't you read the answers you got the first time.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Sebastian Faust | last post by:
Hi, is a construction like the following possible: template<class view_model> class template_clase { protected: template_clase() {} virtual ~template_clase() {}
4
by: Sebastian Faust | last post by:
Hi, I have 4 questions related to templates. I wanna do something like the following: template<typename T> class Template { public: Template_Test<T>()
4
by: Gert Van den Eynde | last post by:
Hi all, A beginners question.... I've got a template class template <class T> classA {...} In an other class, I want to pass a pointer to an instance of classA as a function argument....
21
by: Blue Ocean | last post by:
The reason why I ask is because I am unfamiliar with the idea of templates. It seems like it would be easier if all classes that needed something like template<class T> class Stack { ... } ...
9
by: Jon Wilson | last post by:
I have a class which needs to accumulate data. The way we get this data is by calling a member function which returns float on a number of different objects of different type (they are all the...
6
by: wkaras | last post by:
I tried a couple of compilers, and both gave errors compiling this: template <bool fin, typename T> T foo(T val); template <typename T> T foo<true, T>(T val) { return(val); } But both gave...
4
by: Joseph Turian | last post by:
Hi, What is the correct syntax to get the bar<T>::f<int, unsigned>() function to compile in the following fragment? Thanks, Joseph class foo {
12
by: Ben | last post by:
I'm kind of new to creating templates. I've made some small class and function templates in the past and I have used quite of bit of the STL, but I am having problems tyring to create templates. ...
8
by: Rahul | last post by:
Hi, Is there a way to partially specialize only a member function of a template class (not the whole class). e.g. template <typename A, typename B> class Base { public:
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.