[algogeeks] Re: Cpp problem

2012-05-29 Thread Navin Gupta
Here the const specifies that this is a const memeber function. It means it does not modify its arguments. It means it can be called for const data members. However since a const member function is more generic than non-const member function,it can also be called on non-const data. On Monday, 28

[algogeeks] Re: Cpp problem

2012-05-28 Thread Soumya Prasad Ukil
complex_number const operator =(complex_number temp) const Since, you are returning *this as reference, you have to have const as your return type. You have made your this pointer as constant by appending const keyword at the end of the function signature. But this function has limitation

[algogeeks] Re: Cpp problem

2012-05-27 Thread Lucifer
@amrit Every non-static member function of a class has an implicit parameter that is passed to the function (when called) This implicit parameter is nothing but the this pointer. Now if you want to make the implicit parameter (this pointer) a const, how would u do it? This is done by placing the

Re: [algogeeks] Re: Cpp problem

2012-05-27 Thread Bhaskar Kushwaha
the job of marked const here is to make the member function operator= as const so it can't modify any member function values unless that member function is mutable @manikanta the compiler will throw an error only when we try to modify any members inside a const member function but here we are not

Re: [algogeeks] Re: Cpp problem

2012-05-27 Thread Manikanta Babu
@Bhaskar u r right. I mean wen u are trying to access this function on non constant object. On May 28, 2012 2:08 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: the job of marked const here is to make the member function operator= as const so it can't modify any member function