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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:15:35+00:00 2026-05-26T03:15:35+00:00

For the following definition of const vector3F operator*(const vector3F &v, float s); There are

  • 0

For the following definition of

const vector3F operator*(const vector3F &v, float s);

There are two const, what are their respective usages?

  • 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-26T03:15:36+00:00Added an answer on May 26, 2026 at 3:15 am

    The const-reference in the argument means that you don’t change v, so you can pass constant vectors (and temporaries!) to the function. That’s a Good Thing.

    The constant by-value return is sort of a gimmick. It prevents you from writing things like this:

     vector3F v = get_vector();
     vector3F w = v;
    
     (v * 1.5) = w; // outch! Cannot assign to constant, though, so we're good.
    

    Returning by-value as constant is problematic, though, since it interferes with C++11’s rvalue references and move semantics:

     move_me(v * 1.5);  // cannot bind to `vector3F &&` :-(
    

    Because of that, and because an abuse like the one I showed above is fairly unlikely to happen by accident, it’s probably best to return by value only as non-constant.

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

Sidebar

Related Questions

Consider the following class definition: class StrToTokens { StrToTokens(const char* str, const char* delimiters
I have a following definition. type TOmniTaskDelegate = reference to procedure(const task: IOmniTask); What
Assuming following definition: /// <summary> /// Replaces each occurrence of sPattern in sInput with
I have a WebForm that contains the following definition for the FCKeditor: <FCKeditorV2:FCKeditor ID=txtBody
I have run across an XML Schema with the following definition: <xs:simpleType name=ClassRankType> <xs:restriction
While reading a code I came across, the following definition and initialization of a
Using the following Webservice definition using aClientArgs as a complex type: [System.Web.Script.Services.ScriptService] public class
Lets assume following classes definition: public class A { public final static String SOME_VALUE;
I have the following record definition E3Vector3T = packed record public x: E3FloatT; y:
I have the following class definition: template<typename QueueItemT> class QueueBC { protected: QueueBC() {}

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.