Похожие чаты

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 ответов

6 просмотров

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.

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

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

Quick reminder regarding the first phase of the token merger⚠️ As we approach Phase 1 of the token merger, OCEAN and AGIX will migrate to FET starting July 1st! Here's a li...
Stip11
1
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
Hey, Oceaners 🌊 As we approach Phase 1 of the token merger, OCEAN and AGIX will migrate to FET starting July 1st! Here's a list of exchanges that have communicated their su...
KreigDK | Never DM first🌊
3
VIP 332 Quarterly XVS Buyback, Funds Allocation and New Tokenomics Summary This VIP outlines the protocol’s Quarterly Buyback and Funds Allocation strategy as per our Tokeno...
Venus Announcements
2
База данных не поможет. Шифрование не поможет. Какие там ещё варианты? Накидывайте.
КТ315
20
А табстоп это сообщение от окна или от элемента управления?
The Bird of Hermes
18
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
I love the passion, really do. I do think this is being blown way out of proportion. We are not deleting our Telegram or not allowing you to talk about anything you want, a...
Mike Herron
3
А как лучше конвертировать физический адрес в виртуальный при маппинге? В случае ядра у меня, например, direct mapping, первые 768МБ я как есть мапплю в higher half, а остальн...
Evg Resh
26
Hey, what is the best and maintained way of transpiling cpp to c? (As a need to support many different toolchains quickly and may not have a c++ support in the given toolch...
Meitar Reihan
11
Карта сайта