### No .h fot C++ Standard Library head file and g++ doesn't import the std namespace by default

by Forrest Sheng Bao http://fsbao.net

I want to talk about two common errors people encounter when they compile old programs, especially when they are using recent version of g++. They may wonder why this code can be compiled in g++3.4 but not g++4.3.

A lot people get shock when they see this:

error: fstream.h: No such file or directory

The answer to solve this problem is that "Header files in the C++ Standard Library do not use the .h extension; have have no extension," -Kyle Loudon, C++ Pocket Reference, p.5, O'Reilly, 2003. So instead of saying

#include

, you should say

#include

The second common error is that you have included the library which defines a function, but you still got this:

error: ‘ifstream’ was not declared in this scope

Well, recent versions of g++ does not import std namespace by default. So, you have to add this line

using namespace std;

Above two issues had been address in textbooks a long time ago, at least when I was a college freshman. But I really do not understand why people are still thinking in the old way after so many years.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.19485263526439667, "perplexity": 3090.8486459529113}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-13/segments/1490218186530.52/warc/CC-MAIN-20170322212946-00233-ip-10-233-31-227.ec2.internal.warc.gz"}