0
Where is function body of Getname? Or setName()?
In previous chapter I learned about chapter, where we 1st define function body( type, veriables, statements, etc) then in main function we give function name, which help to direct the control flow of program. class myClass { public: void setName(string x) { name = x; } string getName() { return name; } private: string name; }; but here I saw few function, but no body, so could you tell me please, how it works.
1 Respuesta
0
An example of setter and getter un java
public class Vehicle {
private String color;
// Getter
public String getColor() {
return color;
}
// Setter
public void setColor(String c) {
this.color = c;
}
}