Похожие чаты

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

12 просмотров

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.

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

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

как правильно удалить сддм? прописал в etc/portage.use/plasma-meta -sddm , но при обновлении юзов мне предлагает поставить lightdm (ещё лучше 😡), добавил туда - display-manage...
REDis
25
Except the wealthiest, people that buy crypto want to "cash out" at the end of the day, one way or another. Converting to fiat is craziness, converting to BTC is unwise. Hold ...
Erdelanax
2
#include <stdio.h> #include <stdlib.h> #include <time.h> void mass_first_generate(int mass[5][7]) {     for (int N = 0; N < 5; N++) {         for (int A = 0; A < 7; A++) {   ...
Чувак
6
Всем привет! Решаю 99 OCaml Problems и столкнулся со следующей проблемой (прошу палками не забивать, я OCaml практически не трогал до этого момента): open OUnit2 let create_...
К|/|pи/\/\ 6е3yглbIи
2
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
возможно ли как-то передать в электрон или таури медиа поток с рендера 2д движка? двиг запускается как dll, а дальше надо как-то отправлять рендер кодировать не подходит, зр...
Kyle Nekto
7
https://www.linkedin.com/posts/ugama-benedicta-kelechi-codergirl-103041300_mobiledevelopment-fluttertraining-handsonlearning-activity-7263445699227254784-IdHB?utm_source=share...
CoderGirl
16
like, question: int b = 99999; is this valid and predictable C?
Ludovic 'Archivist' Lagouardette
15
Помогите пожалуйста. Делаю систему плагинов. Проблема сейчас в такая: плагины загружаются в основном потоке. FLibHandle := SafeLoadLibrary(FFileName) Но нужно еще выполнить фу...
Илья 🤣
10
VIP-397 BNBx Oracle implementation upgrade Summary This proposal, if approved, will upgrade the implementation of the BNBx Oracle contract on Venus from version 1 (V1) to v...
Venus Announcements
2
Карта сайта