“this” pointer’s type can be modified in the function declaration by the const and volatile keywords. To declare a function that has either of these attributes, add the keyword(s) after the function argument list.
See the following code,
class Point
{
unsigned X() const;
};
int main()
{
}
The above code declares a member function, X, in which the ‘this’ pointer is treated as a const pointer to a const object. Combinations of cv-mod-list options can be used, but they always modify the object pointed to by the ‘this’ pointer, not the pointer itself.
Remark:The ‘this’ pointer is always a const pointer. It can’t be reassigned. The const or volatile qualifiers used in the member function declaration apply to the class instance the ‘this’ pointer points at, in the scope of that function.
Answer:
“this” pointer’s type can be modified in the function declaration by the const and volatile keywords. To declare a function that has either of these attributes, add the keyword(s) after the function argument list.
See the following code,
The above code declares a member function, X, in which the ‘this’ pointer is treated as a const pointer to a const object. Combinations of cv-mod-list options can be used, but they always modify the object pointed to by the ‘this’ pointer, not the pointer itself.
Remark:The ‘this’ pointer is always a const pointer. It can’t be reassigned. The const or volatile qualifiers used in the member function declaration apply to the class instance the ‘this’ pointer points at, in the scope of that function.
need an explanation for this answer? contact us directly to get an explanation for this answer