Click here to Skip to main content
15,907,328 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
What is const object and const functions.
Posted
Comments
Sergey Alexandrovich Kryukov 6-Nov-12 18:59pm    
What, a problem of reading documentation? Then why would you think you can understand the answers?
--SA

const function: belong a class's member function,

for example:
C++
class CWnd
{
public:
    void ConstFunction() const
    {
        // It's a const function, you can change the member of this pointer.
    }

    void UnConstFunction()
    {
    }
}

// It's a const object, you can't change the member of wnd, you can't call the un-const function of 
// CWnd, such as UnConstFunction.
const CWnd wnd;


[Edit]Code block added[/Edit]
 
Share this answer
 
v2
I would say: "they are constant entities".
I would add: "please, check out the documentation[^]".
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Nov-12 18:59pm    
I would interrupt you: "enough, a 5". :-)
--SA
CPallini 7-Nov-12 3:18am    
:-)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Nov-12 19:00pm    
Well, learn C++. A 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900