-2

I'm new to C++/CLI and are having a hard time with Lists.

I have a structure

#using namespace System::Collections::Generic

struct myStruct {
unsigned int A ; 
int B; };

and i want to create a list with mystructs

List<myStruct> myList;

But that seems not to work, Visual Studio says "myStruct is not a valid generic Argument", but why is that so? And how can i make this structure a "valid generic argument"?

Emil Laine
  • 41,598
  • 9
  • 101
  • 157

1 Answers1

0
#include <List>

struct myStruct {
    unsigned int A ; 
    int B; 
};

std::list<myStruct> myList;

int main(void) {
    return 0;
}
Aify
  • 3,543
  • 3
  • 24
  • 43
  • Try to compile this and see what happens. – molbdnilo May 31 '16 at 09:00
  • @molbdnilo I did compile this - I compiled using Cygwin, using the command `g++ -std=c++11 -Wall test.cpp` and received no warnings. – Aify May 31 '16 at 17:31
  • No, you didn't - there are three serious errors in it. What you possibly did is compile something similar to it and then retype it from memory. In particular, the line with your "correction" is wrong. – molbdnilo May 31 '16 at 19:38
  • @molbdnilo Ah, you're right. I have no idea why this worked for that guy, but the program that is compiling for me right now does look slightly different. It is as you said, the second myStruct turns out to be unnecessary (What IS that second myStruct doing there?). The bigger issue when I pasted this was that I removed the `using namespace std` line and forgot to add back `std::` in front of list. Looks like I need to brush up on my cpp... – Aify May 31 '16 at 19:58