Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What do you mean by a template?

1066


Can you Mention some Application of C/C++?

1068


What is called array?

1074


What do you mean by volatile and mutable keywords used in c++?

984


What do you understand by zombie objects in c++?

1095


What is singleton class in c++?

1037


Can a program run without main in c++?

1198


What are register variables?

1141


How can we read/write Structures from/to data files?

1119


What is a flag in c++?

1052


How long does it take to get good at leetcode?

1166


what are the decision making statements in C++? Explain if statement with an example?

1080


Explain what are mutator methods in c++?

1113


Can I learn c++ without learning c?

1000


What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

1105