From the doc page of that compiler error:
Originally Posted by
C4488
A class must implement all members of an interface from which it directly inherits. An implemented member must have public accessibility, and must be marked virtual.
Code:
public ref class InterfaceImpl : ISomeInterface
{
public:
virtual SomeStruct^ GetStruct()
{
return gcnew SomeStruct();
}
};
Also you're missing the 'ref' off the definition of SomeStruct
Code:
#include "ISomeInterface.h"
namespace Foo
{
ref struct SomeStruct
{
int someValue;
};
public ref class InterfaceImpl : ISomeInterface
{
public:
virtual SomeStruct^ GetStruct()
{
return gcnew SomeStruct();
}
};
}
int main()
{
Foo::InterfaceImpl^ pImp = gcnew Foo::InterfaceImpl();
Foo::SomeStruct^ pStruct = pImp->GetStruct();
Console::WriteLine("pStruct->someValue = {0}", pStruct->someValue);
}
Compiles and runs for me, with a warning that the definition of SomeStruct has only internal visibility. If you want any code from ISomeInterface.cpp or any module other than the one the definition is in to be able to reference it, you'll have to make it public.