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 829567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:54:15+00:00 2026-05-15T03:54:15+00:00

In a lot of C++ API’S (COM-based ones spring to mind) that make something

  • 0

In a lot of C++ API’S (COM-based ones spring to mind) that make something for you, the pointer to the object that is constructed is usually required as a ** pointer (and the function will construct and init it for you)

You usually see signatures like:

HRESULT createAnObject( int howbig, Object **objectYouWantMeToInitialize ) ;

— but you seldom see the new object being passed as a return value.

Besides people wanting to see error codes, what is the reason for this? Is it better to use the ** pattern rather than a returned pointer for simpler operations such as:

wchar_t* getUnicode( const char* src ) ;

Or would this better be written as:

void getUnicode( const char* src, wchar_t** dst ) ;

The most important thing I can think of is to remember to free it, and the ** way, for some reason, tends to remind me that I have to deallocate it as well.

  • 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-15T03:54:16+00:00Added an answer on May 15, 2026 at 3:54 am

    “Besides wanting error codes”?

    What makes you think there is a besides. Error codes are pretty much the one and only reason. The function needs some way to indicate failure. C doesn’t have exceptions, so it has to do that through either a pointer parameter, or the return value, and the return value is idiomatic, and easier to check when calling the function.

    (By the way, there’s no universal rule that ** means you have to free the object. That’s not always the case, and it’s probably a bad idea to use something that arbitrary to remind you of which objects to clean up.)

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

Sidebar

Related Questions

I have found an API that'll make working with CANVAS a lot easier. It
I have built an API framework that includes a lot of communication-related options, including
There are a lot of Cassandra API:s available and usually the programming language preference
I've noticed that in c/c++ a lot of Win32 API structs need to be
I'm working in C# with a Borland C API that uses a lot of
I'm working on an Android app that needs a lot of API calls. I've
I am writing an API that updates a LOT of different fields in a
I have to work with an API that uses a lot of by-reference parameters.
Using Twitter's search API, I'm being returned a helluva lot of information that is
I am currently working on a streaming API that generates a lot of textual

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.