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 a unnitialised pointer?

1138


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

1247


How will you call C functions from C ++ and vice-versa?

1190


Why do we need runtime polymorphism in c++?

1071


How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?

1127


What does count ++ do in c++?

1254


Can we distribute function templates and class templates in object libraries?

1131


Explain the difference between c & c++?

1139


What size is allocated to the union variable?

1127


What is a rooted hierarchy?

1217


What is the this pointer?

1165


What is the auto keyword good for in c++?

1260


Is dev c++ a good compiler?

1014


What is the use of function pointer?

1074


Difference between pointer to constant vs. Pointer constant

1210