0

Hi I want to display a variable menber array queue, and the definitions of the class are The Array.h

template <class DataType>
class Array
{
public:
Array( int size );

private:
T *ele;
};

The Array.cpp

Array<T>::Array( int size )
{
if ( size < 1 ) {
capacity = 1;

}
else {
capacity = size;

}

ele = new T [capacity];
}

Q.h

#include "Array.h"
template <class T>
class Queue
{
public:
Queue( );
void enqueue( T ele );
private:
Array<T> ele;
int front;
int back;
};

Q.cpp

template <class T>
Queue<T>::Queue( )
: ele( 2 ), front( -1 ), back( -1 )
{
}
template <class T>
void Queue<T>::enqueue( T ele )

in the main I have

// I declare a function template fro display the queue
template <T>
void Disply(const DataType elem[] )
{

for( int i = 0; i<6; i++)

cout<< "The elements of the Queue are:\n", i , elem[i]<<endl;

}

int main()
{

Queue<int> elementsArQueue;

int array[]={1,2,3,4,5,6};

for (int a=0;a<6;a++)

queue.enqueue(array);

Display(elementsArQueue.);// give to me some errors like

//P.cpp:

In function int main():
P.cpp:48: error: no matching function for call to Display(Queue<int>&)

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jonsca
0

There are many other things, but you need to have template <class T> before every function definition that uses T (e.g. in array.cpp). Also you pull capacity out of thin air. Make sure your function names are spelled correctly as, within the code you posted you have "Disply" as your function name.

Edited by jonsca: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.