C ++ multiple operator definition >>

I am using the @Martin proposed solution for parsing csv using C ++ , as I am trying to avoid using libraries like boost, etc. for my current project, I put its implementation in the header "csv.h", and I'm trying to include it in some other files. I keep getting the following error:

multiple definition of operator>>(std::basic_istream<char, std::char_traits<char> >&, CSVRow&)

when I try to build a project - I assume that this happens because the redefinition operator>>collides with the original one. How can I make these two games good? thank.

+5
source share
4 answers

, , (.. cpp), , , , .obj, .

3 :

  • - .
  • inline - .
  • cpp.
+8

"csv.h"

. csv.cpp.: -)

+4

.

inline istream & operator>>( istream & is, CSVRow & row ) {
    // stuff
}
+2

, isi-, , ++ . Makefile/Makefile.am/CMakeLists (.a), , .

, , , - ( , ).

0

All Articles