Can I write C++ code without headers (repetitive function declarations)?

前端 未结 24 828
半阙折子戏
半阙折子戏 2020-11-28 07:55

Is there any way to not have to write function declarations twice (headers) and still retain the same scalability in compiling, clarity in debugging, and flexibility in desi

24条回答
  •  清酒与你
    2020-11-28 08:24

    Sorry, but there's no such thing as a "best practice" for eliminating headers in C++: it's a bad idea, period. If you hate them that much, you have three choices:

    • Become intimately familiar with C++ internals and any compilers you're using; you're going to run into different problems than the average C++ developer, and you'll probably need to solve them without a lot of help.
    • Pick a language you can use "right" without getting depressed
    • Get a tool to generate them for you; you'll still have headers, but you save some typing effort

提交回复
热议问题