Linked Questions

306 votes
8 answers
410k views

At this link, the following was mentioned: add.cpp: int add(int x, int y) { return x + y; } main.cpp: #include <iostream> int add(int x, int y); // forward declaration using function ...
Simplicity's user avatar
  • 49.4k
23 votes
2 answers
7k views

Not to say that the Google Style Guide is the holy bible but as a newbie programmer, it seems like a good reference. The Google Style Guide lists the following disadvantages of forward declaration ...
Rufus's user avatar
  • 5,614
8 votes
5 answers
4k views

If I have multiple files that #include each other, and all #include <iostream>, is this considered bad, and if so, how would I avoid it?
iobender's user avatar
  • 3,546
7 votes
5 answers
3k views

I read that #include <file> will copy paste “file” into our source file by C++ preprocessor before being compiled. Does this mean that the “file” (iostream) will also be compiled again and ...
Harsh Pathak's user avatar
0 votes
3 answers
109 views

So I 3 classes as follows: class Weapon { char* name; Target target; int hitStrength; public: Methods... }; class Player { char* name; int level; int life; int ...
kidneyThief's user avatar
0 votes
1 answer
378 views

I would like to understand the pros/cons of forward declaration for classes/structs that are in different files in header only development. I understand that using forward declaration in normal code-...
nionios's user avatar
  • 189
1 vote
1 answer
351 views

pid.h #include <iostream> template <class T> void f(T t); pid.c #include "pid.h" template <class T> void f(T t) { std::cout << t; } template void f<int>(int); pid2....
Kam's user avatar
  • 6,068
1 vote
1 answer
214 views

It is considered best practice to #include <iosfwd> in header files and #include <iostream> only in cpp files. I'm trying to move a lot of #include <iostream> from header to cpp ...
Dev Null's user avatar
  • 5,107
1 vote
2 answers
326 views

I am having a problem with the changes that were made to the way C++ templates are compiled, between the C++17 and 19 standards. Code that used to compile in VS2017 throws a compiler error since I ...
h.s.'s user avatar
  • 253
0 votes
0 answers
36 views

#pragma once #include <iostream> class Duration { private: int hours, minutes, seconds; public: Duration() : hours(0), minutes(0), seconds(0) {} Duration(int s) : hours(s / 3600), ...
tyler99's user avatar
  • 11