quote:Original post by Dirge
c++ rhetoric says ONLY use classes for EVERYTHING
In C++, a struct IS a class, with the ONLY standard difference being that the default access specifier in a struct is public, and in a class private.
It has already been said in this thread too, but apparently, reading is not a requirement for responding anymore.
MSW - there is a potential function call involved with using a function-based modification, yes, but for most short functions the compiler will try to inline it, negating the difference. The keyword 'inline' can be added to demonstrate that you know the function-call overhead might prove a bother, but in the end it's still up to the compiler to decide if it can or cannot inline the function. Usually it does, for short functions like in the example.
[edit: for functions that have their bodies within the class specification (i.e. usually in the header file i.s.o. the CPP file), inline is implied, meaning the compiler will try hard to remove any function-call overhead and some temporary-object construction overhead]
[edited by - MadKeithV on October 22, 2002 5:34:28 AM][edited by - MadKeithV on October 22, 2002 8:29:42 AM]
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.