Why can you not make a constructor as const?

Answer Posted / som shekhar

If the function is declared constant then you are not
intended to change the member variables of the class and if
you did the compiler throws an error.
In this case you can change the variable inside the const
function if the variable is declared as VOLATILE.

Similarly if you declare a variable as const then you cannot
change the value of the variable through its life time.

Now if you declared the constructor then you cannot
initialize the object.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define friend function.

804


What is namespace & why it is used in c++?

813


What is null pointer and void pointer?

851


What is the correct syntax for inheritance a) class aclass : public superclass b) class aclass inherit superclass c) class aclass <-superclass

942


Is c++ low level?

820


Is map ordered c++?

853


What is a responder chain?

819


What are the unique features of C++.

807


What is searching?

883


Do you know what are pure virtual functions?

913


What language does google use?

884


When do we run a shell in the unix system?

846


What is time_t c++?

832


Is eclipse good for c++?

804


What is the use of turbo c++?

788