   CONSTantly looking.
  I've been looking around in every book I have, on other websites, everywhere, for information on the following. What is the difference between the following definitions:void aClass::aFunction();andvoid aClass::aFunction() const;Any ideas?   To be, or not to be, those are the parameters.-----------------------------------------------------To be, or not to be, those are the parameters. [edited by - CaffieneFreak on August 16, 2003 11:50:51 PM]
  ''const'' is used like that to declare member functions which don''t change the state of any of the class'' member variables. For example, accessor functions are almost always const(or should be.) Its good to use when you don''t change member variables; It describes your interface better and maybe leads to quicker compiled code.   Ravyne, NYN Interactive Entertainment[My Site][My School][My Group];  Cool, thank you. Its fairly obvious now I know the answer  -----------------------------------------------------To be, or not to be, those are the parameters. ;  Also, if you have a const object and invoke that method, the const flavor will be invoked.e.g. T& operator[](int i) {return vec[i];const T& operator[](int i) const {return vec[i];}That way with a const vector, you can still index the array, but can''t change it. ;quote:Original post by Magmai Kai Holmlor  Also, if you have a const object and invoke that method, the const flavor will be invoked.e.g. T& operator[](int i) {return vec[i];const T& operator[](int i) const {return vec[i];}That way with a const vector, you can still index the array, but can''t change it.   Neat trick. Thanks. 