While observing an existing code, i see a following statements sometime...can anyone help me to understand what do they mean..?
1-
func1(cl1 a, cl2 b)
{
----
---- datatype obj::readById();
}
...now i wonder why the function readByID was not called using dot operator as it is usually done...this sure calls the function but how it is different from a usual call..?
2-
within the definition a class, i see the following:
void setConCode(const std::string& value);
std::string getConCode() const;
While the fist looks like a usual declaration of a function but i do not understand the syntax of the secod one....can anyone explain..?
1. readById() is a static method of obj, so it doesn't need need an instance to be called.
2. According to a certain book:
If you declare a class method const, you are promising that the method won't change the value of any of the members of the class. void SomeFunction() const;
It seems to me like an utter waste of time to declare anything like that. This is why I skipped const.
It seems to me like an utter waste of time to declare anything like that. This is why I skipped const.
Well, it is important if you are going to have any const instances of your class, since as far as I know the compiler will not let you call any non-const methods of a const class.