error C2955: 'Vector' : use of class generic requires generic argument list

  • Thread starter Thread starter Herby
  • Start date Start date
H

Herby

Iv defined the following class in vector.h

using namespace System::Collections::Generic;

generic<typename T1>
ref class Vector : public List<T1>
{
public:
Vector(void);
};


I would really like to put the implementation in the cpp - is this
still not possible - also with generics?


// vector.cpp

Vector::Vector(void)
{
}

But i get the above error!
Have i just defined it wrong? or must it all go in the header?
 
Herby said:
Iv defined the following class in vector.h

using namespace System::Collections::Generic;

generic<typename T1>
ref class Vector : public List<T1>
{
public:
Vector(void);
};


I would really like to put the implementation in the cpp - is this
still not possible - also with generics?


// vector.cpp

Vector::Vector(void)
{
}

But i get the above error!
Have i just defined it wrong? or must it all go in the header?
With generic it is possible, but similar to templates you have to write

generic<typename T1>
Vector<T1>::Vector(void)
{
}


Marcus
 
Cheers Marcus,

I did just solve that.

I hope your keeping well. I was on your course in London.
 
Iv defined the following class in vector.h

using namespace System::Collections::Generic;

generic<typename T1>
ref class Vector : public List<T1>
{
public:
Vector(void);
};


I would really like to put the implementation in the cpp - is this
still not possible - also with generics?

with templates this is not practically possible since VC does not support
the export keyword. with generics it seems to work without a problem.
// vector.cpp

Vector::Vector(void)
{
}

But i get the above error!
Have i just defined it wrong? or must it all go in the header?

you used the wrong syntax.
this should work in your cpp file:

generic<typename T1>
Vector<T1>::Vector(void)
{
}

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
Thanks guys.
What about operator overloading, is this supported by generics?
Is it part of the CLR?
 
Thanks guys.
What about operator overloading, is this supported by generics?
Is it part of the CLR?

Yes.

Actually I didn't know for sure because I only used overloading on
non-generics.
To test it I've just overloaded the == operator on your generic vector and
it seems to work just fine.

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
Back
Top