[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to improve my question in stackoverflow?



On Thu, Sep 09, 2021 at 04:27:01PM -0600, William Torrez Corea wrote:
> Book.cpp:1:10: fatal error: Set: No existe el fichero o el directorio
> [closed]
> 
> I trying compile an example of a book.

William,

[DISCLAIMER: I'm not a C++ expert by any measure. I do passably
well with C. For example, I don't know whether the C++ #include
directive has some extensions wrt the C one. Please, consult a C++
expert]

this is not a C++ mailing list. You might be luckier elsewhere.

That said...

> The program use three classes: Book, Customer and Library.

... your problem doesn't seem to come from "classes"

> *Book.cpp*
> 
> #include <set>#include <map>#include <string>#include <map>#include
> <fstream>#include <algorithm>using namespace std;

The line above looks very strange. Usually there is one #include
directive per line. Something seems broken with your "book".

Moreover, the included things are files, and by convention they
have a suffix ".h", for "header". I'd expect the above to look
rather like

  #include <set.h>
  #include <map.h>
  #include <string.h>
  #include <map.h>
  #include <fstream.h>
  #include <algorithm.h>

(NOTE: they start at the very beginning of the line: indentation
here is for readability).

Or something similar. Plus, you'd have to adapt your compiler options
for it to actually find those files: quoting them between "<...>" will
direct it to look into /usr/include. A "/usr/include/string.h" does
exist (most of the time ;-), but typically no "/usr/include/set.h", so
you'll have to adapt the compiler call (via the -I option). If your
book doesn't explain this, it is very broken indeed. I'd look for
another book :-)

Likewise, I'd expect that last thing:

  using namespace std;

to appear in a line of itself.

[...]

> g++ -g -Wall  Book.cpp book.h -o book
> 
> The result expected is bad.
> 
> Book.cpp:1:10: fatal error: Set: No existe el fichero o el directorio

Another suggestion: when posting on international mailing
lists, set your locale to something with English error
messages (for example, do "export LANG=C"). Most people
won't be able to understand Spanish error messages.

When asking for help, it helps helping others to help you :)

>  #include <Set>
>           ^~~~~
> compilation terminated.

What this is telling you is that the compiler has looked into
all what it considers to be system directories and hasn't found
a file named like this. Probably not surprising. The code you
showed looks suspicious anyway, as stated above.

> This example was tested from another compiler. The library is not
> recognized.
> 
> *The book is C++17 By Example, published by Packt.*

If your book doesn't tell you (at least roughly) how to talk
to your C++ compiler, I'd suggest looking for another book :)

To direct your compiler to look at some other include directories,
you use the -I option, as stated above. To see where your compiler
is searching for includes, you can do `gcc -xc++ -E -v -' (note: if
it is plain C you are interested in, it would be `gcc -xc -E -v -').

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


Reply to: