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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:51:52+00:00 2026-05-17T18:51:52+00:00

First I found in cplusplus.com the following quote: The catch format is similar to

  • 0

First I found in cplusplus.com the following quote:

The catch format is similar to a regular function that always has at least one parameter.

But I tried this:

try
{
    int kk3,k4;
    kk3=3;
    k4=2;
    throw (kk3,"hello");
}
catch (int param)
{
    cout << "int exception"<<param<<endl;     
}
catch (int param,string s)
{
    cout<<param<<s;
}
catch (char param)
{
    cout << "char exception";
}
catch (...)
{
    cout << "default exception";
}

The compiler doesn’t complain about the throw with braces and multiple arguments. But it actually complains about the catch with multiple parameters in spite of what the reference said. I’m confused. Does try and catch allow this multiplicity or not? And what if I wanted to throw an exception that includes more than one variable with or without the same type.

  • 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-17T18:51:53+00:00Added an answer on May 17, 2026 at 6:51 pm

    (kk3, “hello”) is a comma expression. The comma expression evaluates all of its arguments from left to write and the result is the rightmost argument. So in the expression

    int i = (1,3,4); 
    

    i becomes 4.

    If you really want to throw both of them (for some reason) you could throw like this

     throw std::make_pair(kk3, std::string("hello")); 
    

    and catch like this:

    catch(std::pair<int, std::string>& exc)
    {
    }
    

    And a catch clause has exactly one argument or

    ...
    

    HTH

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

Sidebar

Related Questions

I'm trying to learn some Smalltalk. First found was Squeak, but since it has
I came to know PHP after Perl, so when I first found preg_* function
This is my first time posting -- I found similar issues but not anything
I have read chapter 4 of SICP, and just found that the first section
I am looking for a program to make mockup screenshots with. I first found
problem euler #5 i found the solution but i don't know why this first
First let me say that I really feel directionless on this question. I am
This is a follow up to another question of mine where I first found
I found a bit of code that gets me access to the raw pixel
I don't know enough to change the following so that it only puts <strong>

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.