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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:26:41+00:00 2026-05-31T01:26:41+00:00

I realize this error is usually due to some syntax or type issues but

  • 0

I realize this error is usually due to some syntax or type issues but I am not sure how to solve this problem. I think it may do with the type of findRt.

vector<triangle> findRightTriangles(unsigned long l, unsigned long h) {

<triangle> retval; // storage for return value.

triangle t;    
double what;

for(t.s1 = 3; t.s1 <= h; t.s1++) {
    for(t.s2 = t.s1; t.s2 <= h; t.s2++) {
        what = sqrt((t.s1*t.s1) + (t.s2*t.s2));
        t.s3 = static_cast<unsigned int>(what);
        if(((t.s1*t.s1)+(t.s2*t.s2)) != (t.s3*t.s3) 
            || t.s1+t.s2+t.s3 < l 
                || t.s1+t.s2+t.s3 > h) {
            continue;
        }
        else if(t.s1+t.s2+t.s3 <= h 
            && t.s1+t.s2+t.s3 >= l 
                && t.s1+t.s2 > t.s3 
                    && ((t.s1*t.s1)+(t.s2*t.s2)) == (t.s3*t.s3)) {
            retval.push_back(t);
        }
    }
}
return retval;
}

int main(){

unsigned long min, max;

cin >> min >> max;

    //Here is the problem:
cout << findRightTriangles(min, max) << endl;

return 0;
}

How to output the vector using cout?

  • 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-31T01:26:42+00:00Added an answer on May 31, 2026 at 1:26 am

    Why the error?
    The compiler reports an error because there is no overloaded version of << operator to handle the type vector<triangle> which your function findRightTriangles() returns.
    << is overloaded only for most of the built-in data types and not for custom classes.

    How to output the vector using cout?
    There are two ways:

    Solution 1:
    A two step procedure:

    Step1: You will have to iterate through the vector and cout each contained triangle.

    std::vector<triangle>::const_iterator iter= vec.begin();
    for(iter; iter != vec.end(); ++iter)
    {
        cout<<*iter; //This is what step 2 provides for
    }
    

    Step 2: You will have to overload << for the triangle class as well.

    ostream& operator<<( ostream& os, const triangle &) {}
    

    Solution 2:
    One step Solution.
    Alternately, You can overload << for vector type itself:

    ostream& operator<<( ostream& os, const vector<triangle>&)
    {
    
    }
    

    I would personally prefer the Solution 1. It is more readable & Usually more often than not one would already have an overloaded << for the vector type being used and it could be leveraged.

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

Sidebar

Related Questions

I realize this may be a simple problem, but I am new to ASP.net
I realize this would violate convention, but I'm curious to know if you can
I realize this perhaps a naive question but still I cant figure out how
I realize this is more of a hardware question, but this is also very
I realize this is a rather odd request, but I was wondering if anyone
I realize this is probably a hopelessly newbie question, but what is the difference
I realize this is a basic question but I have searched online, been to
I realize this sounds a little crazy, but I'm working on a project for
I didn't realize this, but apparently Python's strftime function doesn't support dates before 1900:
I realize this type of question has been asked earlier, however I looked everywhere

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.