[英]convert a list of structs from c# to c++
我有以下C#代碼
static void Main(string[] args)
{
List<Results> votes = new List<Results>();
}
public struct Results
{
public int Vote1;
public int Vote2;
public int Vote3;
public Candidate precinctCandidate;
};
public class Candidate
{
public Candidate()
{
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string lastName;
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
}
我想將該代碼轉換為Visual c ++ CLR,謝謝
這是您的代碼到C ++ / CLI的直接翻譯:
using namespace System;
using namespace System::Collections::Generic;
public ref class Candidate
{
public:
Candidate()
{
}
property String^ Name
{
String^ get() { return this->name; }
void set(String^ value) { this->name = value; }
}
property String^ LastName
{
String^ get() { return this->lastName; }
void set(String^ value) { this->lastName = value; }
}
private:
String^ name;
String^ lastName;
};
public value class Results
{
public:
Int32 Vote1;
Int32 Vote2;
Int32 Vote3;
Candidate^ precinctCandidate;
};
int main(array<String^>^ args)
{
List<Results> votes = gcnew List<Results>();
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.