This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: a template question
- From: Travis Spencer <travislspencer at gmail dot com>
- To: Nusret BALCI <balcinus at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 23 Jul 2005 20:17:03 -0700
- Subject: Re: a template question
- References: <20050723072217.12296.qmail@web41015.mail.yahoo.com>
- Reply-to: Travis Spencer <travislspencer at gmail dot com>
On 7/23/05, Nusret BALCI <balcinus@yahoo.com> 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