Похожие чаты

Is it bad idea to include standard libraries like iostream

in the user defined headers? If yes, why?
For example instead of including iostream in my main.cpp program, I included iostream in myheader.h then just include myheader.h in my main.cpp program.

6 ответов

14 просмотров

technically it will work fine but it will increase compilation time if let's say your header is included in 300 cpp files but really used in 10 files so usually you include headers in your header if it needed for this header (e.g. you include vector and you have a class that contains vector as a member) hope I make sense

Пользователь-61653 Автор вопроса
Pavel
technically it will work fine but it will increase...

Oh. Got it. Thank you. You are right. My example header propagated out over 3 files, which 2 of them don't require i/o at all. Thank you very much Pavel

Пользователь-61653 Автор вопроса
Pavel
technically it will work fine but it will increase...

But other than this problem, it doesn't make any problems or errors, yes?

Пользователь 61653
Oh. Got it. Thank you. You are right. My example h...

Just know that adding of headers is the same as pasting content of all included headers. https://code.woboq.org/gcc/libstdc++-v3/include/std/iostream.html includes: https://code.woboq.org/gcc/libstdc++-v3/include/std/ostream.html https://code.woboq.org/gcc/libstdc++-v3/include/std/istream.html and each of them include other headers too. All of this code will be added every time you include your header.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта