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

The Archive Base Latest Questions

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

I was reading a document on operator overloading: http://courses.cms.caltech.edu/cs11/material/cpp/donnie/cpp-ops.html however when I run the

  • 0

I was reading a document on operator overloading: http://courses.cms.caltech.edu/cs11/material/cpp/donnie/cpp-ops.html however when I run the code below (in an actual context) I always get a warning on how result is a local variable. And it makes sense that I shouldn’t be returning a local variable, but it seems to work fine. Is there a way to eliminate the warning with code like the following:

const Matrix & Matrix::operator+(const Matrix &other) const
{
  Matrix result(*this);
  result += other;
  return result;
}

The example on caltech’s website like this, is on the bottom of the link

  • 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-17T14:40:35+00:00Added an answer on June 17, 2026 at 2:40 pm

    To remove the warning, you need to return the Matrix by value.

    You should also ideally define it as a free function since semantically it should not need to modify the object it is called on.

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

Sidebar

Related Questions

I am reading this document to learn Perl's taint mode => http://www.webreference.com/programming/perl/taint/index.html It is
I was reading through this document http://llvm.org/docs/WritingAnLLVMPass.html , where in I came across CallGraphSCCPass
I am reading that document: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24mod $mod The $mod operator allows you to do
I am reading DrRacket document http://docs.racket-lang.org/guide/binding.html There is a function (define f (lambda (append)
I saved my project.apk file, and I was reading this document: http://developer.android.com/guide/publishing/app-signing.html#setup and they
Reading manual about Sling http://sling.apache.org/site/46-line-blog.html added folder blog and blog.html to destination: \launchpad\content\src\main\resources\content\ but
I was reading this document: http://www.fadden.com/techmisc/hdc/lesson11.htm In it he stated: Problem is, we don't
I'm reading an HTML document that contains UTF-8 chars but when I access the
I'm reading a html document using jQuery. Following is my code. I need to
I was reading document about ARC and came across a part which confused me.Please

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.