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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:29:34+00:00 2026-06-17T12:29:34+00:00

So I have a function that requires two characters and two ints: void need_2xcha_2xint(char

  • 0

So I have a function that requires two characters and two ints:

void need_2xcha_2xint(char a, char b, int x, int y)
{
  cout << "Working! a: " << a << ", b: " << b << ", x : " << x << ", y: " << y << ".\n";
}

I would like to call it by passing a single struct that contains the four values:

struct Value_Holder
{
char a;
char b;
int x;
int y;

Value_Holder()
    : a('g'), b('h'), x(3), y(5)
  {
  }
};

I want to be able to call it as follows :

Value_Holder vh;
need_2xcha_2xint(vh);

Of course I could write another function that accepts my custom structure and deals with it appropriate, but I was wondering if there’s a way to tell the struct to output four seperate values directly. This will mainly be used for interacting with DirectX libraries.

I’m sure this is basic stuff, but I’ve been working on so many different areas of c++ it’s hard to remember everything. I’ve searched for the answer for a while now, but I’m not quite sure what I should be searching for. My google skills fail me!

Thanks in advance.

  • EDIT –

As it seems people are confused by my qustions I’ll try and simplify it here:

Is there a way for a function that requires 2 ints and 2 chars to accept a single structure holding these values instead of four seperate values?

I hope that clarifies my question.

  • 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-06-17T12:29:35+00:00Added an answer on June 17, 2026 at 12:29 pm

    Wrap the third party library:

    namespace david {
    
    void need_2xcha_2xint(const Value_Holder& value) {
        ::need_2xcha_2xint(value.a, value.b, value.x, value.y);
    }
    
    }
    

    Using it:

    int main() {
        Value_Holder value;
    
        using david::need_2xcha_2xint;
        need_2xcha_2xint(value);
        return 0;
    }
    

    edit

    I’m pretty sure you could encapsulate this using templates and function pointers.

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

Sidebar

Related Questions

I have a variadic function that requires a double-NULL terminator. Contrived, Simplified Example void
Suppose I have a function test <- function(s,t) { .. } that requires two
I have a PHP function that requires can take 3 parameteres... I want to
$(.container).hover( function(){ $(.child-1).hide(0); $(.child-2).show(0); },function(){ $(.child-1).show(0); $(.child-2).hide(0); }); A project I have requires that
I have a function that returns two values in a list. Both values need
Okay, here is my problem: I have a form that requires to have two
I have a function that requires some vars being appended to a div. One
I have a currency calculator that requires buttons to convert to/from currencies. I'd like
I have a fairly complicated function that takes several double values that represent two
I have a program that calls a Filewatcher function, like this Main() { watch();

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.