I'm trying to convert My Console classes to .Net classes because I can't use std::vector or anything like that in WindowsFormsApplications. So I decided to convert all Vectors to Lists and I thought that the classes work the same but my code below throws a massive amount of errors and I have no clue why.. It's quite short and simple to read.
using namespace System;
using namespace System::Collections::Generic;
template <typename T>
public ref class CustomType
{
private:
List<T> TypeData;
public:
CustomType() {}
CustomType(...array<T^> ^Types) //Basically Variadic Templates.. As good as it gets for MS2010..
{
for each (T^ o in Types)
TypeData.Add(o);
}
~CustomType() {}
int size() {return TypeData.size();}
CustomType& operator [](int I)
{
assert(I >= 0 && !TypeData.empty());
return TypeData[I];
}
const CustomType& operator [](int I) const
{
assert(I >= 0 && !TypeData.empty());
return TypeData[I];
}
operator const List<T>& () const
{
return TypeData;
}
bool operator == (const CustomType &CT) const
{
return (TypeData == CT.TypeData);
}
};
I use the above like this:
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
CustomType<int> Meh(0, 1, 2, 3, 4);
}
But that does not work at all.. It's basically supposed to add Meh to the list within the class and I can access it at anytime to get the data.
Please help me. How do I overload in .Net and what is that Shevron? The ^ operator? I read that it's top level but have no clue what I read because I understood very little. Does ^ Replace the & operator?