Does anyone know if I can send a struct as parameter into a constructor?
Printable View
Does anyone know if I can send a struct as parameter into a constructor?
Like this?
Code:
value struct S
{
System::Int32 n;
};
ref class C
{
S myS;
public:
C(S s)
: myS(s)
{
}
};
It didn´t work for me.
Did it not compile???
What was the error?
error C2664: cannot convert parameter from ':Form1::S ^' to 'Form2::S ^'
Of course the struct name has been replaced, but it was declared into the two classes.
What did you compile? Neither ^ nor 'Teste' apears anywhere in my code. Have you tried compiling my code on its own?
Yes, but the structs are the same. This doesn´t work even with the cast "Form1::S^"
No, they are two separate types. Also stop using ^ it is wrong.
Does my code compile on your compiler or not?
No, it doesn´t.
What is the error message when you compile my code?