我有一个关于测试用户定义头文件的问题。 所以,这里是例子。测试用户定义头文件和其他问题
#include <iostream>
using namesapce std;
#include "header.h"
#include "header.h" // I wonder the reason why I need to write this down two time for testing ifndef test.
int main()
{
cout << "Hello World!" << endl;
cin.get();
}
我知道我需要在driver.cpp中记下两次用户定义的头文件名。但是,我不明白为什么我需要这样做。
而且,这是第二个问题。
#include <iostream>
#include <fstream>
using namesapce std;
int main()
{
fstream fin;
fin.open("info.txt");
if(!fin.good()) throw "I/O Error\n"; // I want to know what throw exactly do.
else cout << "Hello World!\n";
cin.get();
}
所以,我的问题是扔功能。 我意识到,如果我使用throw而不是cout,我的编译器将被终止。 我想知道什么投掷确切做。
由于我是新来的人,我可能在格式和一些规则方面犯了一些错误,所以请随时指出它们,如果我做到了。
谢谢!
太谢谢你了! –