vendredi 28 octobre 2016

Using getter, setter in c++

i wanna use class in c++ what has a integer array like it:

class A{
private:
        int arr[50];

}

and i will read something from text file like it:

sum i1 i2

thats means:sum of arrays index1 and index2 and store in index1

so, how can i do it, with using getters and setters like:

seti2(geti1()+geti2())

or something like it, ( because its not verys useful, i dont want to write getter and setter for every index geti1() geti2() ... geti50() )

do you have any idea?

by the way, my second question is that, is getter should not have any parameters and is setter should have only one parameter?

Aucun commentaire:

Enregistrer un commentaire