Linked Questions

54 votes
4 answers
40k views

Possible Duplicates: [C] Header per source file. In C++ why have header files and cpp files? C++ - What should go into an .h file? Is the only reason header files exist in C so a developer can quickly ...
alex's user avatar
  • 492k
21 votes
4 answers
28k views

Possible Duplicate: In C++ why have header files and cpp files? I don't quite get C++ header files, for two conflicting reasons: I thought the purpose of header files was in general to separate ...
NoobOverflow's user avatar
  • 1,278
12 votes
3 answers
4k views

I have only just started learning C++, and I see that functions are usually declared and defined separately, for example: // Declaration void sayhi(std::string name); // Definition void sayhi(std::...
jshji's user avatar
  • 316
3 votes
1 answer
9k views

Someone asked a question similar to mine here: Function declaration inside or outside the class? Why do you just declare a function inside a .h file but not the definition, and then write the whole ...
laquishabonquiquithe3rd's user avatar
4 votes
3 answers
6k views

Possible Duplicate: In C++ why have header files and cpp files? Coming from a C# background, I find header files really annoying. Are they necessary even with C++11?
Vittorio Romeo's user avatar
2 votes
3 answers
4k views

I was wondering if it is advisable to write a the whole class c++ in a header file ? and use include to include the class, in a similar way that java does its oop programming. Is it a bad style ? can ...
George Host's user avatar
0 votes
3 answers
2k views

Possible Duplicate: In C++ why have header files and cpp files? I was reading some KDE tutorials for creating basic plasma widgets and other QT stuff. One thing that I noticed is almost all the ...
Shashwat's user avatar
  • 269
2 votes
1 answer
4k views

I wonder why recommended way is to #include<example.hpp> in example.cpp; I don't understand, how preprocessor (which seems to be quite simple program) knows that definition of methods are in ...
GingerPlusPlus's user avatar
0 votes
3 answers
578 views

Possible Duplicate: In C++ why have header files and cpp files? C++ - What should go into an .h file? All the functions/methods which are usually defined in .cpp file can be defined inline in .h ...
user avatar
0 votes
2 answers
1k views

So im trying to make a Die class and a LoadedDie class where the Die class is the base and the LoadedDie class is derived. The only difference between the 2 classes is that the roll function in the ...
ShadowViper's user avatar
1 vote
2 answers
484 views

I am a student programmer learning my first language with the book "Accelerated C++." I am at at a point where the author is explaining header files and source files containing functions. In the ...
Brandon Feist's user avatar
0 votes
1 answer
415 views

When using multiple files in C++, for example: main.cpp, definition.cpp, declaration.h // declaration.h int Myfunc(); //definition.cpp #include "declaration.h" int MyFunc() {return 5;}; //...
Viktor Skarve's user avatar
-1 votes
3 answers
237 views

Possible Duplicate: In C++ why have header files and cpp files? Why in C++ is there a .h and .cpp and not only one file like c# and Java ?
Guillaume Paris's user avatar
0 votes
1 answer
173 views

In C++, I've heard that you need to separate the implementation from the interface in order to reduce compile times. In this question, the answerer basically says that if you change the header then ...
M3579's user avatar
  • 910
0 votes
1 answer
253 views

I may be thinking/using header files the wrong way, but currently I'm using 1 .cpp file and the rest are all in header files. I have things like a screen which is an array of characters in a header ...
Gavin C.'s user avatar
  • 105
0 votes
1 answer
101 views

The header's file content is put where .h file is used. Why use add.h in add.cpp? In case without using header file add.cpp // There is not declaration int add(int x, int y); int add(int x, int y) { ...
Eto Tenma's user avatar
-1 votes
1 answer
110 views

I'm new to c++ and I have 'actually' learned a lot these past days. I just learned how to link multiple files today or what I think is called, using "headers". My question is related to headers and ...
Cayman's user avatar
  • 19
0 votes
1 answer
122 views

I understand the header file contains all the prototypes of every function contained in the implementation file; but what is the real purpose? Is it because when another program calls on the class, it ...
Colin's user avatar
  • 1,866
1 vote
1 answer
89 views

I was working with sockets , and i noted that a lot of the code i wrote repeated in different programs , so i wrote functions for most of the stuff that i did and saved them in a ".c" file without a ...
Tabish Imran's user avatar
0 votes
3 answers
110 views

So I have a problem when using a singleton Game class and the Story class. Game.hpp #ifndef GAME_HPP #define GAME_HPP #include <memory> class Phase; // Forward declaration class Game { ...
cozycoder's user avatar
1 vote
0 answers
98 views

I'm learning C ++ and I have a question about header files. Are they only for classes? If I have some functions and want to use them in several files, should I write the declaration in the h file and ...
jTymbark's user avatar
2 votes
0 answers
82 views

my first project in c++ (I use g++ on centos) from Python and c#, I use to split my program into few files, each class in different file. The most common reason i find, why use .h file, is ...
orenk's user avatar
  • 119
-4 votes
1 answer
79 views

I been searching a lot lately about header files and stuff and i always see the same things, but i dont get something, why use the .h header file when you can just throw the code on the .cpp file? ...
Graziano Bolla's user avatar
0 votes
0 answers
73 views

Why is there a need to include the header file of a class into the implementation file of the same class?? Does it serve a purpose?? Since i thought it is needed only where we need to use that class.
Saurabh's user avatar
  • 447
0 votes
1 answer
65 views

I came across this implementation of some code which requires us to create a header and then #include it in our source code. So my question is why we need to create a .cpp file along with the .h and ...
Jayakrishna Menon's user avatar
0 votes
0 answers
60 views

When we write class in c++ we divide class into two part that header file and cpp file. In header file we define class and prototype Class.h class A{ public: void functionName(); }; Then we define ...
Victor Fries985's user avatar
0 votes
1 answer
53 views

Comming from a mostly Java background I recently started learning a bit of C++. I'm trying to create a class that describes a LinkedList. Since I want this class to be something like an external ...
apboutos's user avatar
  • 119
0 votes
0 answers
48 views

I'm having a general question about header files: In my project, which is not a library or plugin, but a standalone program, I don't use any header files - I am just using cpp files that I include in ...
tagelicht's user avatar
  • 497
0 votes
0 answers
41 views

I'm a beginner to C++ and I am getting extremely confused trying to understand the benefits of the recommended practices regarding headers and implementation files. Say I have two implementation ...
Mohannad Shehadeh's user avatar
0 votes
1 answer
42 views

Hello i have a code like this in c++: #include <iostream> using namespace std; namespace exercises { class String; ostream& operator<<(ostream&, const String&); istream&...
myOwnWays's user avatar

15 30 50 per page