The compiler is complaining about my default parameters?

前端 未结 2 1202
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 11:25

I\'m having trouble with this piece of code , after i took this class from the main.cpp file and splitted it in to .h and .cpp the compiler started complaining about the def

2条回答
  •  独厮守ぢ
    2020-12-23 11:57

    Alright! It worked (a bit weird though because it was working fine when i had the whole code in one file).

    I also had this problem when I started moving code around into multiple files. The real problem was that I forgot to write

    #pragma once
    

    at the top of the header file, and so it was redefining the functions multiple times (each time the header file was being invoked from a parent file), this caused the redefinition of default parameter error.

提交回复
热议问题