Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6380121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:13:36+00:00 2026-05-25T02:13:36+00:00

Given the following test interface (C#): public interface ITest { UInt32 Simple(UInt32 someArg); byte*

  • 0

Given the following test interface (C#):

public interface ITest
{
    UInt32 Simple(UInt32 someArg);

    byte* Read(UInt32 count);
    void Write(byte* buf, UInt32 count);

    byte[] ReadArray(UInt32 count);
    void WriteArray(byte[] buf);
}

Can I implement this interface in c++/cli? I’ve tried a million different ways; currently I have this:

typedef unsigned __int32 uint32;
typedef unsigned char byte;

public ref class CTest : public ITest
{
  virtual uint32 Simple(uint32 someArg);

  virtual byte * Read(uint32 count);
  virtual void Write(byte * buf, uint32 count);

  virtual System::Array<byte>^ ReadArray(uint32 count);
  virtual void WriteArray(System::Array<byte>^ buf);
}

The VC2010 compiler complains bitterly about all of the methods except CTest::Simple, claiming I haven’t implemented the interface.

Can someone show me the c++/cli magic to implement an interface that passes either byte* or byte[] (preferably both)? I’m at my wit’s end…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:13:36+00:00Added an answer on May 25, 2026 at 2:13 am

    The following compiles:

    public ref class CTest : public ITest
    {
    public:
        virtual unsigned Simple(unsigned someArg) { return 0u; }
    
        virtual unsigned char* Read(unsigned count) { return nullptr; }
        virtual void Write(unsigned char* buf, unsigned count) { }
    
        virtual array<unsigned char>^ ReadArray(unsigned count) { return nullptr; }
        virtual void WriteArray(array<unsigned char>^ buf) { }
    };
    

    Your main problem is the fact that your CTest member functions are private and thus ineligible to implement the interface. The other problems are mostly related to using System::Array<> rather than array<> (which is short for cli::array<>).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Confusing question, I know. Given the following: class Test { public static void GenericFunc<T>(T
Given a function which accepts a parameter with the following interface: interface ITest {
If we have the following sample application: interface ITest { string Test { get;
Given the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span>
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Given following Ruby statements: (Read input and store each word in array removing spaces
Given the following: &row->count Would &(row->count) be evaluated or (&row)->count be evaluated in C++?
I'm new to Moq and I wonder how I could write the following test
Given the following SUT, would you consider this unit test to be unnecessary? **edit
I have the following: namespace Test { public class Location { public string city

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.