《c++ primer plus》第二章练习题 C++报错 error: ‘print1‘ was not declared in this scope

正在自学C++,想要把出现的错误记录一下~
看的书是《C++ primer plus》第六版中文版
在练习第二章 2.7 编程练习的第三题出现如下错误:
《c++ primer plus》第二章练习题 C++报错 error: ‘print1‘ was not declared in this scope错误的意思是“print1”没有被定义。
错误原因:C++是先调用main()函数,而在调用main()函数的时候,自定义的print1()没有在main()函数之前被定义。
解决办法1:在int main()之前加入void print1();和void print2();

《c++ primer plus》第二章练习题 C++报错 error: ‘print1‘ was not declared in this scope解决办法2:把main函数体放到print1()和print2()函数后面。
《c++ primer plus》第二章练习题 C++报错 error: ‘print1‘ was not declared in this scope