1

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.

Stals
  • 1,453
  • 3
  • 26
  • 50
  • Not an exact duplicate, but the answers to http://stackoverflow.com/questions/4702579/c-linking-with-namespaces-causes-duplicate-symbol-error/4702707#4702707 answer your question. – Edward Strange Jan 16 '11 at 11:15

1 Answers1

2

use #ifdef to guard against multiple redefinitions.

also look at this post: #pragma once vs include guards?

Community
  • 1
  • 1
Viren
  • 2,123
  • 22
  • 27
  • 1
    +1. Also note that this has nothing to do with your specific problem but is a general advice: your header files should all have include guards. – ereOn Jan 16 '11 at 11:17