, . COM- List<T> - COM, , , std::list. COM .
UPDATE
ArrayList , - , , tlb . , IList. ( #import .tlh, IList, .)
, . :
[Guid("7366fe1c-d84f-4241-b27d-8b1b6072af92")]
public interface IStringCollection
{
int Count { get; }
string Get(int index);
}
[Guid("8e8df55f-a90c-4a07-bee5-575104105e1d")]
public interface IMyThing
{
IStringCollection GetListOfStrings();
}
public class StringCollection : List<string>, IStringCollection
{
public string Get(int index)
{
return this[index];
}
}
public class Class1 : IMyThing
{
public IStringCollection GetListOfStrings()
{
return new StringCollection { "Hello", "World" };
}
}
, ( ) . , StringCollection Count, List<string>.
++:
#include "stdafx.h"
#import "..\ClassLibrary5.tlb"
#include <vector>
#include <string>
using namespace ClassLibrary5;
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(0);
IMyThingPtr thing(__uuidof(Class1));
std::vector<std::string> vectorOfStrings;
IStringCollectionPtr strings(thing->GetListOfStrings());
for (int n = 0; n < strings->GetCount(); n++)
{
const char *pStr = strings->Get(n);
vectorOfStrings.push_back(pStr);
}
return 0;
}
++, .
, , , .
, ++/CLI? , CLR std-.