• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ When do I need to change both files (header and .cpp) ?

drakylucas

Intermediate OT User
Joined
Dec 15, 2015
Messages
236
Solutions
7
Reaction score
121
I'm with this doubt...
Like, in the TFS, there are some small functions that are implemented only in the header files... So, what is the general rule about it, when do I need to just write the header and implement in the cpp file, and when I need just to implement in the header file?


example:
player.h
Code:
        static uint64_t getExpForLevel(int32_t lv) {
            lv--;
            return ((50ULL * lv * lv * lv) - (150ULL * lv * lv) + (400ULL * lv)) / 3ULL;
        }

player.h
Code:
        void setName(std::string name) {
            this->name = std::move(name);
        }
these functions (and many others) are implemented on header files only.


Thanks all!
 
Back
Top