By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?

Mar 14 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Herby" <pr********@gmail.com> wrote in message
news:11*********************@e56g2000cwe.googlegro ups.com...
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
Mar 14 '06 #2

P: n/a
Cheers Marcus,

I did just solve that.

I hope your keeping well. I was on your course in London.

Mar 14 '06 #3

P: n/a
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.
br**********************@hotmail.com
Remove only "_nos_pam"

Mar 14 '06 #4

P: n/a
Thanks guys.
What about operator overloading, is this supported by generics?
Is it part of the CLR?

Mar 14 '06 #5

P: n/a
> 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.
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 14 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.