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 upgraded a MS Visual Studio Application from VS 2003 to VS 2008
I have a Visual Studio 2008 C# .NET 2.0CF application where I need to
I have a Web Application project in Visual Studio 2008. (lucky you, you say?
I have a Windows Forms application in C#/Visual Studio 2008 with an IE WebBrowser
I have created a setup project using Visual Studio 2008. After the application is
Is there a way to have Visual Studio 2008 automatically add heading information to
I have a WinForms application built using Visual Studio 2008. I added a Setup
I have visual studio 2008 installed on my PC. Can anyone tell me what
I have Visual Studio 2008 Professional and I am having issues with expanding and
I have Visual Studio 2008 with SP1 installed and it is crashing when I'm

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.