Thread overview
What's wrong with this template?
Jan 06, 2006
BCS
Jan 06, 2006
Sean Kelly
Jan 06, 2006
BCS
Jan 06, 2006
Ivan Senji
Jan 06, 2006
BCS
January 06, 2006
this code:
vvvvvvvv
class T(int i)		// line 1
{
	T!(i) dup()
	{
		return new T!(i);
	}
}

void main()
{
	T!(1) t = new T!(1);
}
^^^^^^^^
gives these errors:

(3): template instance T is not a template declaration, it is a class
(3): T!(1) is used as a type
(5): template instance T is not a template declaration, it is a class
(5): T!(1) is used as a type
(11): T!(1) is used as a type

What an I doing wrong?
January 06, 2006
BCS wrote:
> this code:
> vvvvvvvv
> class T(int i)        // line 1
> {
>     T!(i) dup()
>     {
>         return new T!(i);
>     }
> }
> 
> void main()
> {
>     T!(1) t = new T!(1);
> }

Try this:

class T(int i)        // line 1
{
    T dup()
    {
        return new T();
    }
}

void main()
{
    T!(1) t = new T!(1);
}
January 06, 2006
Thanks!!

Now, how about this:


class T(int i)        // line 1
{
    T!(i+1) inc()
    {
        return new T!(i+1)();
    }
}

void main()
{
    T!(1) t = new T!(1);
	T!(2).T t2 = t.inc();
}


can you use a template inside it's self?

Sean Kelly wrote:
> BCS wrote:
> 
>> this code:
>> vvvvvvvv
>> class T(int i)        // line 1
>> {
>>     T!(i) dup()
>>     {
>>         return new T!(i);
>>     }
>> }
>>
>> void main()
>> {
>>     T!(1) t = new T!(1);
>> }
> 
> 
> Try this:
> 
> class T(int i)        // line 1
> {
>     T dup()
>     {
>         return new T();
>     }
> }
> 
> void main()
> {
>     T!(1) t = new T!(1);
> }
January 06, 2006
BCS wrote:
> Thanks!!
> 
> Now, how about this:
> 
> 
> class T(int i)        // line 1
> {
>     T!(i+1) inc()

Try .T!(i+1)
January 06, 2006
Ivan Senji wrote:
> BCS wrote:
> 
>> Thanks!!
>>
>> Now, how about this:
>>
>>
>> class T(int i)        // line 1
>> {
>>     T!(i+1) inc()
> 
> 
> Try .T!(i+1)


BINGO, that's just what I needed!