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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:09:03+00:00 2026-06-17T08:09:03+00:00

Are all of the below declarations the same? If so, what is the standard

  • 0

Are all of the below declarations the same? If so, what is the standard way to declare a constant function?

const SparseMatrix transpose();

SparseMatrix transpose() const;

const SparseMatrix transpose() const;
  • 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-17T08:09:04+00:00Added an answer on June 17, 2026 at 8:09 am

    The const on the left of the function name means the object that is returned cannot be modified. The const on the right means the method is apart of a class and does not modify any of its data members. Unless or course any of its data members are declared with the mutable keyword, in which case modification thereof is permitted despite a const guard.

    The placement of the const keyword is unimportant when the return type of the function is of non-pointer type:

     T const f(); // same as const T f();
    

    However, note that the placement of the const keyword matters when using a pointer as the return type. For example:

    const T* f();
    

    This method returns a pointer to a const T. That is, what it points to is immutable. So you cannot do an assignment through a dereference of the returned pointer:

    T* x = f();
    
    *x = y; // error: assignment of read-only location '*(const T*)x'
    

    When const is placed on the immediate right of the return type (that is a pointer), it means the pointer is const and cannot be changed.

    T* const f();
    
    int main()
    {
        T* x const;
    
        x = f(); // error: assignment of read-only variable 'x'
    }
    

    Furthermore, if we have const on both sides of a pointer return type, and have const denoting “no modification of class members”, then it’s read as the following:

    const T* const f() const;
    

    A const member function named f that returns a const pointer to a const T

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

Sidebar

Related Questions

Hi All below is the code which i use. <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
Below all my code, * Model * Below is Model code, public class MyViewModel
I'm being a little lazy here but are these (below) all the default Backbone
I'm getting the following error: Encoding::UndefinedConversionError: \x81 from ASCII-8BIT to UTF-8 The below all
I know that technically all three ways below are valid, but is there any
I'm using all of the below to take a field called 'code' from my
I have an array of array like below with all numeric values. I want
I want to know if the code below removes all input type='text' values back
All of the names below are generic and not the actual names used. I
Consider the below 2 declarations. * appears next to the datatype and not next

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.