This shows you the differences between two versions of the page.
|
poo-is-ab:tema:00 [2024/12/07 13:45] razvan.cristea0106 [Exemplu complet] |
poo-is-ab:tema:00 [2024/12/07 13:51] (current) razvan.cristea0106 [3. Formatare] |
||
|---|---|---|---|
| Line 38: | Line 38: | ||
| * **Acolade**: Stil Allman (acoladele deschise pe linie separată). | * **Acolade**: Stil Allman (acoladele deschise pe linie separată). | ||
| + | <code cpp> | ||
| class MyClass | class MyClass | ||
| { | { | ||
| Line 46: | Line 47: | ||
| } | } | ||
| }; | }; | ||
| + | </code> | ||
| * **Lungimea liniei**: maxim 80 de caractere. | * **Lungimea liniei**: maxim 80 de caractere. | ||
| Line 61: | Line 63: | ||
| }</code> | }</code> | ||
| * **Getter și Setter**: | * **Getter și Setter**: | ||
| - | * Getterele trebuie să fie constante (ex. ''int getValue() const;''). | + | |
| + | * Getterii trebuie să fie constanți (ex. ''int getValue() const;''). | ||
| * Metodele care nu modifică obiectul trebuie să fie declarate const. | * Metodele care nu modifică obiectul trebuie să fie declarate const. | ||
| - | <code> | + | |
| + | <code cpp> | ||
| class MyClass | class MyClass | ||
| { | { | ||
| Line 71: | Line 75: | ||
| public: | public: | ||
| int getValue() const { return m_value; } | int getValue() const { return m_value; } | ||
| - | void setValue(int value) { m_value = value; } | + | void setValue(const int& value) { m_value = value; } |
| - | };</code> | + | }; |
| + | </code> | ||
| ===== 5. Alte recomandări ===== | ===== 5. Alte recomandări ===== | ||