Quote:Original post by Driv3MeFar
Using directives are generally bad practice in header files, because now any file that includes that header will be using that namespace. This can lead to some hard to track down name collisions if you're not careful.
That's true, but in case anyway wants to know, you can also just use a specific part of a namespace, by having:
using std::cout, for example.
Quote:Original post by daviangel
You'd think the error messages would at point you in the right direction for such a simple mistake?
Yeah, i think they should fix that, but they probably think that if your a programmer then you should be able to realize the mistake. When i saw all the errors, i was like what the hell did i do wrong? My code looked perfectly fine to me.
Quote:Original post by agh-ha-ha
Once you learn how headers really work, the errors make as much sense as they can. A #include statement effectively replaces its self with the contents of the file you are including. So when the compiler finishes doing the pre-processor step (swapping #includes for the included files content and resolving #defines etc.) it just sees a big "file" with all the headers inlined. When you don’t include a file you need to, some of the definitions that are referenced in the original c/cpp file can’t be found in the pre-processed "file". This causes the compiler throws the errors that it does because they make perfect sense. (Even the errors that are caused by a missing semi-colon in a header file, which, appear at first, to make no sense at all)
Well, I already sort of know the way they work (pretty much similar to the way you just described), but the problem was that errors didn't really relate to a missing include. They mainly just say "missing )", "missing ;", etc.