Class and class-helpers
-
11-10-2019 - |
Question
I am new to c++ and want to ask about class helpers.
Well, i have a class and i what class helpers to be in other file. For that i should use namespaces but then i cant #include this file multiple times(because of redefinition).
What is the right way to make class helpers in other classes? Should i use static classes for that?
UPD: Ok i get the fitst part, but should i use namespaces or static classses for class helpers? (I dont really see any benefit of using classes instead if namespaces , but i am a newbie so i am not sure). UPD2: Oh. With a class for this i can make sub-classes for helper class.
Solution
use #ifdef to guard against multiple redefinitions.
also look at this post: #pragma once vs include guards?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow