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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:45:07+00:00 2026-06-14T14:45:07+00:00

Hello i am new to C++ and im trying to make a program that

  • 0

Hello i am new to C++ and im trying to make a program that takes two complex numbers, sumarizes them and return the sum.

What i am planning to do is sending two tuples into a function and returning one tuple.

typedef tuple<float, float> complex_tuple;
  complex_tuple a_tuple(a, b);
  complex_tuple b_tuple(c, d);


    cout << sum(a_tuple, b_tuple);

and this is my function:

tuple<float,float> sum(tuple<float, float>a, tuple<float, float>b){
  float a_real= get<0>(a);
  float a_imag= get<1>(a);
  float b_real= get<0>(b);
  float b_imag= get<1>(b);
  return tuple<float, float>(a_real+b_real, a_imag+b_imag);
}

the error i get is:

0.cc:28:31: Error: no match for "operator<<" in "std::cout << sum(std::tuple<float, float>, std::tuple<float, float>)(b_tuple)"

What am i doing wrong?

  • 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-14T14:45:09+00:00Added an answer on June 14, 2026 at 2:45 pm

    You are trying to say that you want to print the sum to cout, but cout doesn’t know how to handle values of type complex_tuple.

    Provide an overload of operator<<(ostream&, const complex_tuple&) to allow the code to compile:

    ostream& operator<<(ostream& os, const complex_tuple& tuple) {
        os << get<0>(tuple) << "+" << get<1>(tuple) << "i";
        return os;
    }
    

    Further information.

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

Sidebar

Related Questions

hello im new and learning javascript. I'm trying to make a program of addition
Hello I am trying to make a C# program that downloads files but I
I'm trying to make a program in Java that can read, compile, and run
Hello I am new to android dev and admob. I am trying to make
hello im trying to make something like github treeslider im new to javascript.. but
Hello i was trying to make function with PDO but getting error (new to
Hello all im new to jquery and im trying to make a edit inplace
Hello i am new to monotouch and i am trying to make an app
Hello all im trying to make this slide effect http://tinyurl.com/628z32d but im new to
Hello I am new to Git and trying to setup server part and client

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.