return const pointer

hey,
can u please explain what is returned from this function?
can u please tell me what kind of operation can I do on the returned value?
the function:
1
2
3
4
5
        // _sum is my private attribute in this class  
	int* get_pointer_to_sum() const
	{
		return _sum;
	}

1
2
3
4
5
6
7
int main(){
        // is  this operation is right?
	int* pMoney = get_pointer_to_sum();
	add_sum(*pMoney);
	*pMoney = 100;
        pMoney++;
}

thanks.

can u please explain what is returned from this function?

_sum.

The operations are valid, assuming an appropriate add_sum function exists, that you actually call the function on an object and that _sum points to a valid int instance and is not a member array.
Dereferencing the pointer after the last line would no longer be valid.
Last edited on
Topic archived. No new replies allowed.