Skip to content
Related Articles

Related Articles

Improve Article
C++ | const keyword | Question 2
  • Difficulty Level : Medium
  • Last Updated : 28 Aug, 2013

In C++, const qualifier can be applied to
1) Member functions of a class
2) Function arguments
3) To a class data member which is declared as static
4) Reference variables
(A) Only 1, 2 and 3
(B) Only 1, 2 and 4
(C) All
(D) Only 1, 3 and 4


Answer: (C)

Explanation: When a function is declared as const, it cannot modify data members of its class.

When we don’t want to modify an argument and pass it as reference or pointer, we use const qualifier so that the argument is not accidentally modified in function.

Class data members can be declared as both const and static for class wide constants.

Reference variables can be const when they refer a const location.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :