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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:31:19+00:00 2026-06-14T22:31:19+00:00

I have a simple question, because I don’t understand the functionality correctly. Having the

  • 0

I have a simple question, because I don’t understand the functionality correctly.
Having the code like that:

int function(a, b)
{
 return a*b;
}

it is clear for me that if a and b are int then it returns the result.
However having such:

int function1(arg1, arg2)
{
 //something
 if (B)
 {
  //do something
  return;
  }
 arg1[0] = variable1;
 arg1[1] = variable2;
 arg2 = variable3;
 return;
}

I want to name the interfaces, so inputs and outputs, and put the function body into the ‘blackbox’. Inputs are those that are arguments of the function, am I correct? Then outputs is integer array arg1 and the integer arg2, is that right? If so, how can input be output, or if I’m wrong how to identify it?
Also, what happens if B is true, at the return point? Does a function1 return nothing? If so, why is not void type?
sorry for a little bit chaos and for such funny example, but thanks to that I’m gonna be able to understand the concept.

  • 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-14T22:31:21+00:00Added an answer on June 14, 2026 at 10:31 pm

    This code is actually invalid C++:

    int function(a, b)
    {
     return a*b;
    }
    

    It is invalid because function parameters must have type, and a and b don’t have a type specified. This would be valid:

    int function(int a, int b)
    {
     return a*b;
    }
    

    If you want to design a function that can accept parameters of unspecified type, you can use templates for that:

    template<class Val>  Val function(Val a, Val b)
    {
      return a*b;
    }
    

    This will work for any type (such as int) so long as that type makes sense when used with operator* as with a*b.. For example, std::string won’t work.

    In C++, all functions that are declared to return a type must return that type at every return point. That makes this code also invalid:

    int function1(arg1, arg2)
    {
     //something
     if (B)
     {
      //do something
      return;
      }
     arg1[0] = variable1;
     arg1[1] = variable2;
     arg2 = variable3;
     return;
    }
    

    You cannot return void from a function declared to return an int. If you need to “escape” from a function that is declared to return something, you can throw an exception:

    int function1(arg1, arg2)
    {
     //something
     if (B)
     {
      //do something
      throw std::runtime_error("whoops");
      }
     arg1[0] = variable1;
     arg1[1] = variable2;
     arg2 = variable3;
     throw std::runtime_error("whoops 2");
    }
    

    However, given the context of this question I suspect this is not what you’re looking for, and you should consider exceptions to be an advanced topic for now. these are not the droids you’re looking for.

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

Sidebar

Related Questions

i have a simple question, there is a function with parameter emp_id that opens
I'm new to Java so I have a simple question that I don't know
This is going to be a very simple question, I have code that looks
I have a question that I couldn't find the answer because I don't know
Simple question, I think. I have org.springframework.scheduling.quartz.CronTriggerBean triggering one job once a day. Because
I have a simple question and that is how do you check if an
seems like a simple question but I don't know JavaScript too well and my
I have very simple question that I cannot find the answer to. In the
Simple question. If I have BOOL a = [myInst function]; NSAssert(a, @...) then I
Simple question but I don't know why it is not printing correctly or 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.