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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:32:23+00:00 2026-06-08T18:32:23+00:00

I tried to follow google c++ style guide . i have a setter for

  • 0

I tried to follow google c++ style guide . i have a setter for private memeber – age.

My problem is what should be the name of the setAge argument?
In java i have both the same name and ditinguish between them by using the this keyword.

void setAge(int age){
     this.age = age;
} 

What is the coding style to do this in c++ (google coding style is preferred).

  • 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-08T18:32:24+00:00Added an answer on June 8, 2026 at 6:32 pm

    The google C++ coding standards suggest that you add a trailing underscore to class data members. I think it is very important to follow this, otherwise you are guaranteed to hide a class data member with a local variable name.

    Concerning getters and setters, I personally find getX and setX convenciton tedious, when it is obvious what a method does.

    int age() const; // gets age, what else could it do?
    
    void age(int age); // sets age, following the principle of least surprise.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using Simple-form and Bootstrap and I have tried to follow this
While using the Google code website, I have tried using the command prompt to
I've tried to follow the advice of this question: Facebook, Django, and Google App
I try to google, but I can't fixed my problem. Many people have this
I have a problem with printing web fonts from Google chrome v 18 but
I tried to follow many online tutorials to run kmeans example present in Mahout.
I tried to follow this but the default modelbinder let my array null on
I just got out of a small project and I've tried to follow a
I want to tail multiple files (and follow them) in CentOS, I've tried this:
I have tried unsuccessfully to copy the pwd to pbcopy as follows pwd |

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.