Using non-template functions in template classes?

You have to declare the function inline (or alternatively move the definition to a single translation unit) The problem that you are facing is that if you define the function in the header, and include that header in more than one translation unit, the compiler will generate the function in all translation units When the linker tries to generate the program (or library) it finds that the function is defined multiple times and complains about it, as that is a violation of the ODR (One Definition Rule). By marking the function as inline the compiler will flag that function so that when the linker sees the multiple definitions instead of choking it will discard all but one of the definitions.

You have to declare the function inline (or alternatively move the definition to a single translation unit). The problem that you are facing is that if you define the function in the header, and include that header in more than one translation unit, the compiler will generate the function in all translation units. When the linker tries to generate the program (or library) it finds that the function is defined multiple times and complains about it, as that is a violation of the ODR (One Definition Rule).

By marking the function as inline the compiler will flag that function so that when the linker sees the multiple definitions instead of choking it will discard all but one of the definitions.

Thanks. Inline worked fine. I've tried to move the definition to a single translation unit, but I think I did it wrong :) – karlicoss Apr 18 at 20:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions