I am following exercise from Mr Stroustrup book Programming Principles and practice using C++ page 122, there is example about temperature.
however I need second pair of eyes, I am missing something.
I have custom header included. (I am trying not to use using namespace std;
and I typed code I think without any mistakes. However, my VS is complaining about problem with function sort(). it should have two parameters, were as in book there is only one temps.
I have custom header included. (I am trying not to use using namespace std;
Do you realize that that custom header is "using namespace std;"?
However, my VS is complaining about problem with function sort(). it should have two parameters, were as in book there is only one temps.
That header also has a sort() function with only one parameter that is not in the std::namespace. I suggest, for now, you avoid using the std:: specifier.
Also be careful, that header also "modifies" std::vector and std::string to add range checking.
Lastly that header already #includes most, if not all, headers you should need for programs contained in the first dozen or so chapters.
I did remove most of the #include apart from custom library, however sort still is showing as error. I looked inside std_lib_facilities and there is nothing about sort().
IMO that header "std_lib_facilities.h" should be an all or nothing file. Either you #include it to use it's features, including the #include statements or you don't #include it and then you don't try to use any of the features from that header. Also IMO that header should be after any of the standard #include statements.
As I said the original header file defined a function named sort() with one parameter. If you removed that portion of the header you will need to find the documentation for and use std::sort instead if his "helper" function. By the way this is the code from the original header:
And if you decide to use that #include file, make sure you have the #include file that matches the book revision, there may be differences in this header for the different book revisions.
Normally I don't use that header file, at the beginning I didn't know how to use it (ie where to put it how to add to VS, later I didn't need to :D) however with this example sort function didn't work so I was trying other things and finally i gave it a go with header from website with address (or at least I tought it was ) from my book:
Heh Jlb - thank you!! I just found solution to my problem, thanks to your quote about different versions of the file, i started looking on the site again and found this: