contain class

B

BjoernJackschina

Hello,
Up to now I failed to find out how I can fill a container class like
following example:
template<class T>
class field
{
explicit field(int value=0):n(value),t(new T[groesse]){}
private:
int n;
T* t;};
I need the right function and I would be glad about any example.
 
J

jd

Le Mon, 27 Dec 2004 05:03:04 -0800, BjoernJackschina a écrit :
Hello,
Up to now I failed to find out how I can fill a container class like
following example:
template<class T>
class field
{
explicit field(int value=0):n(value),t(new T[groesse]){}
private:
int n;
T* t;};
I need the right function and I would be glad about any example.

What do you mean ? do you want to construct such template class
(making an instance of it) ?
Or do you want to use std containers with such types ?
 
J

Jonathan Mcdougall

BjoernJackschina said:
Hello,
Up to now I failed to find out how I can fill a container class like
following example:
template<class T>
class field
{
explicit field(int value=0):n(value),t(new T[groesse]){}

What's "groesse"?
private:
int n;
T* t;};
I need the right function and I would be glad about any example.


std::vector< field<int> > v;

v.push_back( field<int>(10) );

You cannot have

std::vector< field > v;

because field is not a type nor a class, it is a class template. Read about
that on google (we had a discussion a couple of days ago).

Jonathan
 

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,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top