Palabra primeraPalabra(0,"");
Palabra ultimaPalabra(0, "");
Palabra palabraTemp(0, "");
A critical issue with the given header file can be seen in the following lines. you are creating 3 instances of a class inside a header file
First of all, we should ask ourselves: "What is a header file?"
suppose you have many many function declarations and your program has many different classes and structs definitions. Well, one option is to put them all inside a .cpp file. Well, that would be very messy and the code wouldn't be that modular. The question we should ask ourselves is: "How can we seperate our function & methods definitions & declarations and classes & structs definitions into different & unique files?"
Unsurprisingly, header files can help us.
Suppose you have 2 classes A & B, and you wish to separate their declarations and definitions into different files.
Here's the conventional way to do it:
A.h - A file that will contain declarations related to A only
A.cpp - A file that will contain implementations of the functions & methods declared in A.h
B.h - A file that will contain declarations related to A only**
B.cpp - A file that will contain implementations of the functions & methods declared in B.h
One might ask: "How would you use the functions and methods declared in header files?"
In order to include a header file in your source code you can type the following above your C/C++ code
#include "filename.h"
************** Extra Note **************
Before someone screams at me in the comments - Yes, template functions implementations should to be in the header file and not in a cpp file
If you aren't aware of what templates are - https://en.wikipedia.org/wiki/Template_(C%2B%2B) (Extra material)
But that's a whole different topic
************** Extra Note **************
How would that compile?????????
Well, between compilation and the final executable there's a middle stage called linking.
a linker is responsible for combining all of the used header files specified; You can read more about the linking process here: https://en.wikipedia.org/wiki/Linker_(computing)
Conclusion - the problem in the code
You essentially wrote lines for creating 3 instances of a class in a header file.
These lines are completely out of place and were probably written there by accident, however, due to the fact that you specified you are new to the way header works this is a general introduction with a few buzz-words you can feel free to google. If you have any question, ask me in the comments!