Re: a template question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/23/05, Nusret BALCI <balcinus@xxxxxxxxx> wrote:
> I'm trying to compile the following code:

Where is the rest of it?  What do the _Environment_ and stack classes
look like?  Do they look something like this:

typedef int data_type;

template <typename T>
class stack
{
public:
    data_type *get_array(int);
};

template <typename T> class _Environment_
{
public:
    stack<T> *vstack, *stack;
};

Am I close?

> template <typename data_type, int stack_size>
> class Array
> {
>         public:
> static data_type* get_array(int length)
> {
>         if(!_Environment_<stack_size>::vstack)
>                 return
> _Environment_<stack_size>::stack->get_array<data_type>(length);
>         else
>                 return
> _Environment_<stack_size>::vstack->get_array<data_type>(length);
> }
> };

How do you instantiate Array objects?  Like this maybe:

Array<int, 10> a;

If so, then _Environment_ would look like this in the get_array method:

return _Environment_<10>::vstack->get_array<int>(length);

But `_Environment_<10>' doesn't make any sense.  The compiler wants a
type not a value.

> Unfortunately I have no access to a linux
> machine, therefore I'm stuck with MinGW

Linux is free you know ;-)

-- 

Regards,

Travis Spencer


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux