0

I am getting 'class' type redefinition, which I understand is because class A is in both the header and the cpp file. which both look like this:

header.h

namespace NS {
  class A : B {
    // Definitions Here
  }
}

main.cc

namespace NS {
  class A : B {
    void DoSomething(){}
    void DoSomethingElse(){}
  }
}

I have read that I need to convert the main.cc file to look like this:

namespace NS {
  void A::DoSomething(){}
  void A::DoSomethingElse(){}
}

I am not a huge fan of how that looks, so is there a way for me to format it like the first example without getting the redefinition error by maybe changing the header file?

Get Off My Lawn
  • 34,175
  • 38
  • 176
  • 338
  • 1
    "I am not a huge fan of how that looks" this is just how the language was defined. Fighting the syntax of the language often leads to heavy abuse of macros and stuff like that... dont go there, its dark and evil and cold :P – 463035818_is_not_an_ai Sep 13 '18 at 16:35
  • I know it was defined like that I was just hoping there was another way it could be written. Some languages allow for multiple syntax styles. I was hoping c++ was one of them, since I prefer that style... – Get Off My Lawn Sep 13 '18 at 16:41
  • sure, its always good to know the limits of what is possible and what not. I just wanted to remind that even if in fact everything is possible, its not always wise to do so ;) – 463035818_is_not_an_ai Sep 13 '18 at 16:44

0 Answers0