'foo' was not declared in this scope c++

后端 未结 3 1060
醉话见心
醉话见心 2020-11-27 19:52

I\'m just learning c++ (first day looking at it since I took a 1 week summer camp years ago)

I was converting a program I\'m working on in Java to C++:



        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 20:40

    In general, in C++ functions have to be declared before you call them. So sometime before the definition of getSkewNormal(), the compiler needs to see the declaration:

    double integrate (double start, double stop, int numSteps, Evaluatable evalObj);
    

    Mostly what people do is put all the declarations (only) in the header file, and put the actual code -- the definitions of the functions and methods -- into a separate source (*.cc or *.cpp) file. This neatly solves the problem of needing all the functions to be declared.

提交回复
热议问题