Eclipse - Tips'n tricks - Generating getters and setters from the Source menu

An easy way to generate getters and setters is to use the Source option within Eclipse Indigo.

For example, create a new file, add the following lines and select them:

int nbPeople;
int nbAnimal;

Then right click.
On the menu select Source > Generate getters and setters.
On the new window, click on the right Select All, then Next and Finish.

Your getters and setters are generated for you as follows:

int getNbAnimal() const
    return nbAnimal;

int getNbPeople() const
    return nbPeople;

void setNbAnimal(int nbAnimal)
    this->nbAnimal = nbAnimal;

void setNbPeople(int nbPeople)
    this->nbPeople = nbPeople;

Thanks a lot dear Eclipse wink

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.