When I build it, it returns an error in the ".cpp".
The error is that neither "titulo" or "nodo->autor" are declared in their scopes.
My question is, in the private, must I put something like "struct nodo{ string titulo; string autor; etc..} or maybe the problem is in the constructor?
Thanks.
////////////////////////////////////////////////////////////////////////////////
#include "book.h"
// Estructura de Libros
#include <iostream>
#include <string>
using namespace std;
Just a nit, but generally it's good practice to pass strings by reference; you're currently passing them by value.
Use void book::CargaAutor(const string& a);
To indicate that A) You're accepting a reference ("&"), which means you are directly accessing the string object that the function was called with (which is very efficient for heavy weight types like string), and B) You won't be making any changes to that object ("const"), as all you're doing is assigning a field to it.
Also, if you're not doing anything in the constructor or destructor, you should just not declare them. The compiler will generate default implementations for you.
The problem is that in the .cpp file you are not prefixing the method names with the name of the class ("book"). As sujitnag pointed out, it needs to be qualified as void book::CargaTitulo(int t) { }
In order to define it.
Without that the compiler thinks you are just defining a free-floating function called "CargaTitulo", so referencing class members doesn't work, hence the error.
One thing to note though, there actually isn't anything preventing you from just defining the methods inline in the header file, and dropping the .cpp file altogether. Just define the methods where you declare them in the class, and it will be fine.