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>&)

Check out:
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13

It's touchy about template parameters being defined in separate compilation units. It probably has to do with your DataType parameter being used in a function with your T parameter in main. I did not try your code so I'm not positive.

P.S. What's up with that font? hehe

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.