how to new some class from template

J

Jianli Shen

template is this:

template <class Data>
class FastQueue{

public:
FastQueue(int size){ }


}

I declare myQueue;
FastQueue<DInst *> myQueue;


I don't want to initialize it in constructor use myQueue(32)

I need use new to initialize it:

trie:
myQueue = new FastQueue<DInst *>::FastQueue(32)

failed, don't know how to do

Thanks for help!
 
J

Jianli Shen

error get is :


no matching function
for call to `FastQueue<DInst*>::FastQueue()'
...../FastQueue.h:52: candidates are:
FastQueue<DInst*>::FastQueue(const FastQueue<DInst*>&)
...../FastQueue.h:63:
FastQueue<Data>::FastQueue(unsigned int) [with Data = DInst*]
 
V

Victor Bazarov

Jianli said:
error get is :


no matching function
for call to `FastQueue<DInst*>::FastQueue()'
..../FastQueue.h:52: candidates are:
FastQueue<DInst*>::FastQueue(const FastQueue<DInst*>&)
..../FastQueue.h:63:
FastQueue<Data>::FastQueue(unsigned int) [with Data = DInst*]




Jianli Shen said:
template is this:

template <class Data>
class FastQueue{

public:
FastQueue(int size){ }


}

I declare myQueue;
FastQueue<DInst *> myQueue;


I don't want to initialize it in constructor use myQueue(32)

I need use new to initialize it:

trie:
myQueue = new FastQueue<DInst *>::FastQueue(32)

Drop the '::' and the "constructor name". Do


First of all your variable has to be a pointer, and second, you the 'new'
expression needs a type, not a "constructor name".

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
sxarexu

Latest Threads

Top