I'm working my way through Stroustrup's Programming Principles And Practice Using C++, and I have reached chapter 12.
In this chapter, you are required to use the FLTK graphic library.
Since the description in the book is a bit outdated, I had to search around a bit for a usable guide. This is the one I ended up going with:
https://bumpyroadtocode.com/2017/08/29/how-to-install-and-use-fltk-1-3-4-in-visual-studio-2017-complete-guide-2-0-no-cross-contamination/
After a bit of troubleshooting I managed to get to the fourth and final step.
In it, you link up all the headers as well as repeating some of the earlier steps to run this piece of code:
#include "Graph.h"
#include "Simple_window.h"
int main()
{
using namespace Graph_lib;
Point tl(150, 150);
Simple_window win(tl, 600, 400, "My window");
win.wait_for_button();
}
But after a lot of checking and rechecking I still getting around 15 errors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Severity Code Description Project File Line Suppression State
Warning C4018 '<': signed/unsigned mismatch C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\window.cpp 59
Warning C4244 '=': conversion from 'double' to 'int', possible loss of data C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 56
Warning C4244 '=': conversion from 'double' to 'int', possible loss of data C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 57
Error C2440 'initializing': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 74
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 148
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 169
Error C2664 'Graph_lib::Text::Text(const Graph_lib::Text &)': cannot convert argument 1 from 'std::string' to 'const Graph_lib::Text &' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 169
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 175
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 180
Error C2660 'Graph_lib::Lines::add': function does not take 1 arguments C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 180
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 190
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 195
Error C2660 'Graph_lib::Lines::add': function does not take 1 arguments C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph.cpp 195
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\simple_window.h 13
Error C2661 'Graph_lib::Button::Button': no overloaded function takes 4 arguments C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\simple_window.h 13
Error C2440 'initializing': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\graph_drill.cpp 15
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\gui.cpp 67
Error C2440 '<function-style-cast>': cannot convert from 'initializer list' to 'Graph_lib::Point' C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\gui.cpp 71
Warning C4018 '<': signed/unsigned mismatch C12 - Graphic Drill c:\users\simon\source\repos\c12 - graphic drill\c12 - graphic drill\window.cpp 61
|
I was hoping someone here could help me solve this problem, as I have no idea how to deal with this at my current level and the guy who made the guide, doesn't seem to respond to comments, currently.
I've linked the sources and headers below.
std_lib_facilities.h:
https://pastebin.com/JRHi5Pze
fltk.h:
https://pastebin.com/3khmmh3b
Graph.h:
https://pastebin.com/DteUSwe5
GUI.h:
https://pastebin.com/4Sp8bUfv
Point.h:
https://pastebin.com/grdpYX7F
simple_window.h:
https://pastebin.com/L7tcWy96
Window.h:
https://pastebin.com/3uWeEWeG
graph_drill.cpp:
https://pastebin.com/AxQ22Efw
Graph.cpp:
https://pastebin.com/MsQHDgEt
Window.cpp:
https://pastebin.com/ySUzcZZh
I should mention, that I decided to add the paths to “library directories” and “additional include directories” to the release versions, even though the guide didn't mention it, as otherwise, I would get linking errors about the program being unable to find the source file “FL/Fl_Window.h”.
Regards
Simon