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

  • SEARCH
  • Home
  • 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 4060152
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:18:07+00:00 2026-05-20T15:18:07+00:00

I have a visual studio 2008 C++ application where I need to get information

  • 0

I have a visual studio 2008 C++ application where I need to get information from a function that takes a variably sized buffer. So, I have a class that backs that type with a std::vector and implements a conversion operator to the type I want.

class CMibIpForwardTable
{
public:
    operator MIB_IPFORWARDTABLE* () 
    { 
        return reinterpret_cast< MIB_IPFORWARDTABLE* >( &buffer_.front() ); 
    }

    ULONG size() const
    {
        return buffer_.size();
    }

    void resize( ULONG size )
    {
        buffer_.resize( size );
    }

private:
    std::vector< BYTE > buffer_;
};

CMibIpForwardTable Get( DWORD* error_code = NULL )
{
    CMibIpForwardTable table;
    ULONG size = 0;

    DWORD ec = ::GetIpForwardTable( NULL, &size, FALSE );
    if( ec == ERROR_INSUFFICIENT_BUFFER )
    {
        table.resize( size );
        ec = ::GetIpForwardTable( table, &size, TRUE );
    }

    if( NULL != error_code && ec != 0 ) 
        *error_code = ec;
    return table;
}

I would like to be able to use it like this:

CMibIpForwardTable table = Get();

// error: 'dwNumEntries' : is not a member of 'CMibIpForwardTable'
DWORD entries = table->dwNumEntries;

Is there a good way to get access to the underlying type MIB_IPFORWARDTABLE? Or am I stuck doing something like this:

MIB_IPFORWARDTABLE* t = table;
DWORD entries = t->dwNumEntries;

Thanks,
PaulH

  • 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-20T15:18:08+00:00Added an answer on May 20, 2026 at 3:18 pm

    Just overload operator-> in addition to the conversion operator.

    MIB_IPFORWARDTABLE* operator-> () { ... }
    const MIB_IPFORWARDTABLE* operator-> () const { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Visual Studio 2008 C++ application where I'm using a custom allocator
I have developed an application using Entity Framework , SQL Server 2000, Visual Studio
I have been using windows XP. I installed visual studio 2008 and sql server
I have a sample ASP.NET application that I will use in classroom setting. Each
I have a windows form application which has a text box and 3 buttons.
I have created desktop application wherein there are three projects include. any one can
this is kind of tricky: I have an C# web application running always on
I am choosing between using WPF or Windows Forms for my application UI. We
One web site is required to be accessed by me (developer) and one user
I recently got a new primary computer. On my old one, I was working

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.