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 is implicit pointer in c++?

1089


What does the nocreate and noreplace flag ensure when they are used for opening a file?

1119


What is overloading unary operator?

1093


What is difference between c++ and c ++ 14?

1058


Describe the syntax of single inheritance in C++?

1082


What is the difference between ++ count and count ++?

1148


Explain linear search.

1065


What is a pointer with example?

1264


Explain static and dynamic memory allocation with an example each.

1114


Explain function overloading

1022


What are the various oops concepts in c++?

1048


What is the use of main function in c++?

978


How would you use the functions memcpy(), memset(), memmove()?

1098


what is multi-threading in C++?

1057


Why is c++ difficult?

1053