除了-Wall之外,其他人发现的警告有用吗?
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html
添加.h:
int add(int x, int y); // function prototype for add.h -- don't forget the semicolon!
Run Code Online (Sandbox Code Playgroud)
为了在 main.cpp 中使用这个头文件,我们必须 #include 它(使用引号,而不是尖括号)。
主要.cpp:
#include <iostream>
#include "add.h" // Insert contents of add.h at this point. Note use of double quotes here.
int main()
{
std::cout << "The sum of 3 and 4 is " << add(3, 4) << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
添加.cpp:
#include "add.h"
int add(int x, int y)
{
return x + y;
}
Run Code Online (Sandbox Code Playgroud)
嗨,我想知道,为什么我们在文件 add.cpp 中有#include“add.h”?我认为没有必要。