New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Is it ok to use const keyword before the void(or any return type) while declaring and defining the constant method of object?
Syntax https://sololearn.com/compiler-playground/cMWOIAqZXQYg/?ref=app
1 Answer
+ 4
Yes but it does make a difference
"myPrint() const" means that the method is const
"const void myPrint()" means that the return type is const. Which is anyways meaningless because its void
So basically the "const void myPrint()" doesnt make the method constant. It makes the return type