Hi Guys,

I need some help in accessing elements from a list. I am using Visual Studio 2008 (c++).

Here's my code:

using namespace System::Collections::Generic;

public ref class Cord
{
  public: int numCord;
  public: int x, y, z;
};

public ref class Poly
{
  public: Cord c1, c2, c3;
};

//Declare the lists
List<Cord^>^ cordList = gcnew List<Cord^>();
List<Ploy^>^ polyList = gcnew List<Poly^>();

//Add cords to the list
for(int i =0; i < 12; i++)
{
  Cord^ newCord = gcnew Cord();

  newCord->x = i+1;
  newCord->y = i+2;
  newCord->z = i+3;
  newCord->numCord = i;

  cordList->Add(newCord)
}

//Add polys to the list
for(int i = 0; i < 3; i++)
{
  Poly^ newPoly = gcnew Poly();
  newPoly->c1 = cordList[i];
  newPoly->c2 = cordList[i+1];
  newPoly->c3 = cordList[i+2];
  polyList->Add(newPoly);
}

now every thing upto adding the cords into cordList works fine. But when I try to do newPoly->c1 = cordList; etc.... and try to compile I get the error
error C2582: 'operator =' function is unavailable in 'Cord'
I have researched this error and looked at the msdn help but couldn't find a solution for it.
I have no idea why this is not working. c1,c2,c3 are of type Cord and cordList contains Cords. I am not sure if I am using the Cord class properly to declare the Poly class.
Any help would be appreciated as I am totally stumped.

>>error C2582: 'operator =' function is unavailable in 'Cord'
This means there is no default assignment operator for type Cord, you need to implement one. This error would not happen in C++.

RANT ALERT!
This is C++/CLI, not C++. So you will probably find better luck looking for answers by restricting yourself to the domain of C++/CLI. Because the above syntax and the error you get have no relationship to C++, and that's probably why no one else has answered yet. C++/CLI is a completely different programming language, and yet another perverse attempt by Microsoft to get .NET to swallow all the code in the world! But they are only driving all good programmers further and further away by these C# and CLI attempts at seducing C++ programmers, all they accomplish is getting inexperienced programmers do develop a useless skills at C# and CLI, while good, experienced C++ programmers move to other companies and other operating systems!
END OF RANT.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.