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

The Archive Base Latest Questions

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

Possible Duplicate: auto reference in c++11 The more I learn C++, the more I

  • 0

Possible Duplicate:
auto reference in c++11

The more I learn C++, the more I have come to realize that so far (almost; see below) everything in it basically just makes sense. I find that I don’t really have to learn any rules by heart because everything behaves as expected. So the main thing becomes to actually understand the concepts, and then the rest takes care of itself.

For instance:

const int ci = 0;
auto &a = ci;       //automatically made const (const int &)

This works and makes sense. Anything else for the type of a would just be absurd.

But take these now:

auto &b = 42;       //error -- does not automatically become const (const int)
const auto &c = 42; //fine, but we have to manually type const

Why is the first an error? Why doesn’t the compiler automatically detect this? Why does the const have to be typed out manually? I want to really understand why, on a fundamental level so that things make sense, without having to learn any rigid rules by heart (see above).

  • 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-17T09:40:34+00:00Added an answer on June 17, 2026 at 9:40 am

    The type of 42 is int, not const int.

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

Sidebar

Related Questions

Possible Duplicate: Auto-Initializing C# Lists I have a list of integers that has a
Possible Duplicate: Using bind1st for a method that takes argument by reference I have
Possible Duplicate: Mobile site - force landscape only / no auto-rotate I have seen
Possible Duplicate: Push-Notification Badge auto increment. I have implemented Push Notification for my iPhone
Possible Duplicate: mysql auto_increment by 5? I have a table that will have a
Possible Duplicate: Why does ASP.NET auto-generated .designer code have the incorrect type? On my
Possible Duplicate: Auto-size dynamic text to fill fixed size container. Let's say i have
Possible Duplicate: Auto-format structured data (phone, date) using jQuery plugin (or failing that vanilla
Possible Duplicate: Auto Submitting a form (cURL) I have a form which submits to
Possible Duplicate: Location of parenthesis for auto-executing anonymous JavaScript functions? I'm curious now that

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.