Hello everybody,
I'm wondering about these accessors and what the benefit that I would get from them i understood what "set function" is for,
but i didn't get it with the "get function ".
even thought i searched about this topic in this site and one "Expert " tried to explain it through the car example and something with speed......
any way,
by the way some people even the author D.S Malik use at the end of heading of it the keyword "const" so what the benefit of it if it can't change the values
may be this example will deliver my point
[code=cpp]
consider this in the main function
int main()
{
clockType myclock;
clockType yourclock;
int hours;
int minutes;
int seconds;
.
.
.
.
}
void clockType::getT ime (int &hours, int &minutes, int &seconds) const
{
cout << "getTime is started at the body of it \n";
hours = hr;
minutes = min;
seconds = sec;
cout << "getTime is ended at the body of it \n";
}
[/code]
** and how the compiler would know which object to deal with "myclock" or "yourclock" //consider the parameters list it is called by reffrence
I didn't get it, so please if any one explain it in the easiest way i would be greatful for him
********My english is not that good so please use simple terms********** *********
thanks alot
I'm wondering about these accessors and what the benefit that I would get from them i understood what "set function" is for,
but i didn't get it with the "get function ".
even thought i searched about this topic in this site and one "Expert " tried to explain it through the car example and something with speed......
any way,
by the way some people even the author D.S Malik use at the end of heading of it the keyword "const" so what the benefit of it if it can't change the values
may be this example will deliver my point
[code=cpp]
consider this in the main function
int main()
{
clockType myclock;
clockType yourclock;
int hours;
int minutes;
int seconds;
.
.
.
.
}
void clockType::getT ime (int &hours, int &minutes, int &seconds) const
{
cout << "getTime is started at the body of it \n";
hours = hr;
minutes = min;
seconds = sec;
cout << "getTime is ended at the body of it \n";
}
[/code]
** and how the compiler would know which object to deal with "myclock" or "yourclock" //consider the parameters list it is called by reffrence
I didn't get it, so please if any one explain it in the easiest way i would be greatful for him
********My english is not that good so please use simple terms********** *********
thanks alot
Comment