What are two reasons that you might want to use the const keyword in a class definition (.h file)? (Choose only 2) a. To create a global variable (like pi) that will be accessible to all classes and files in your program. O b. To modify the object itself to make it so that any instances of it will be constant in all contexts. O c. To make it so an object passed into a function cannot be modified within that function. O d. To make a function able to be called by constant objects (make it constant qualified)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter13: Overloading And Templates
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question

What are two reasons that you might want to use the const keyword in a class definition?

What are two reasons that you might want to use the const keyword in a class definition (.h file)? (Choose only 2)
a. To create a global variable (like pi) that will be accessible to all classes and files in your program.
O b. To modify the object itself to make it so that any instances of it will be constant in all contexts.
O C. To make it so an object passed into a function cannot be modified within that function.
O d. To make a function able to be called by constant objects (make it constant qualified)
Transcribed Image Text:What are two reasons that you might want to use the const keyword in a class definition (.h file)? (Choose only 2) a. To create a global variable (like pi) that will be accessible to all classes and files in your program. O b. To modify the object itself to make it so that any instances of it will be constant in all contexts. O C. To make it so an object passed into a function cannot be modified within that function. O d. To make a function able to be called by constant objects (make it constant qualified)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr