Stroustrup's Graph.h
Stroustrup's Graph.h
本文关键字:Graph Stroustrup 更新时间:2023-10-16
我正在学习Stroustrup的"Programming Principles…"。我试图得到一个简单的窗口程序编译,并没有运气在linux或windows。
最终,在多个问题之后,我试图包括我从他的网站得到的Graph.h,没有别的。我的错误如下(我不知道现在该怎么做,因为我假设他的代码是正确的)
$ g++ window.cpp
In file included from /usr/include/c++/4.5/ext/hash_map:60:0,
from /home/nathan/Documents/c++/std_lib_facilities.h:34,
from /usr/include/c++/4.5/Window.h:12,
from window.cpp:1:
/usr/include/c++/4.5/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
In file included from window.cpp:2:0:
/usr/include/c++/4.5/Graph.h: In constructor ‘Graph_lib::Rectangle::Rectangle(Point, Point)’:
/usr/include/c++/4.5/Graph.h:203:43: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘<unresolved overloaded function type>’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h:203:55: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘<unresolved overloaded function type>’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h: In constructor ‘Graph_lib::Circle::Circle(Point, int)’:
/usr/include/c++/4.5/Graph.h:286:26: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h:286:32: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h: In member function ‘Point Graph_lib::Circle::center() const’:
/usr/include/c++/4.5/Graph.h:290:49: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘const int’ to binary ‘operator+’
/usr/include/c++/4.5/Graph.h:290:63: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘const int’ to binary ‘operator+’
/usr/include/c++/4.5/Graph.h: In member function ‘void Graph_lib::Circle::set_radius(int)’:
/usr/include/c++/4.5/Graph.h:292:57: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h:292:71: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’`enter code here`
/usr/include/c++/4.5/Graph.h: In constructor ‘Graph_lib::Ellipse::Ellipse(Point, int, int)’:
/usr/include/c++/4.5/Graph.h:302:33: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h:302:40: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h: In member function ‘Point Graph_lib::Ellipse::center() const’:
/usr/include/c++/4.5/Graph.h:306:49: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘const int’ to binary ‘operator+’
/usr/include/c++/4.5/Graph.h:306:62: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘const int’ to binary ‘operator+’
/usr/include/c++/4.5/Graph.h: In member function ‘Point Graph_lib::Ellipse::focus1() const’:
/usr/include/c++/4.5/Graph.h:309:55: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator+’
/usr/include/c++/4.5/Graph.h:311:66: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator+’
/usr/include/c++/4.5/Graph.h: In member function ‘Point Graph_lib::Ellipse::focus2() const’:
/usr/include/c++/4.5/Graph.h:316:55: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h:318:66: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h: In member function ‘void Graph_lib::Ellipse::set_major(int)’:
/usr/include/c++/4.5/Graph.h:322:56: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h:322:70: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h: In member function ‘void Graph_lib::Ellipse::set_minor(int)’:
/usr/include/c++/4.5/Graph.h:324:56: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h:324:69: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator-’
/usr/include/c++/4.5/Graph.h: In member function ‘void Graph_lib::Image::set_mask(Point, int, int)’:
/usr/include/c++/4.5/Graph.h:372:65: error: cannot resolve overloaded function ‘x’ based on conversion to type ‘int’
/usr/include/c++/4.5/Graph.h:372:74: error: cannot resolve overloaded function ‘y’ based on conversion to type ‘int’
我不知道粘贴我所有的代码是否失礼,但无论如何。我找遍了所有地方,这两天一直在努力。我现在有理由感到沮丧。请帮助。
是否包含正确的Point.h
(Graph.h
取决于Point.h
)?也许在找到"原则"示例之前,编译器会发现其他Point.h
文件。
g++ -M Window.cpp
可以帮助您确定。
我把整个示例拉下来,发现我必须修复Graph.h
中的两行才能使其编译,但它们与您在Point.h
或Point
类型上得到错误的行无关。
在Graph.h
的第140-142行,我必须更改:
private: // prevent copying
Vector_ref(const Vector&);
Vector_ref& operator=(const vector&);
:
private: // prevent copying
Vector_ref(const Vector_ref&);
Vector_ref& operator=(const Vector_ref&);
我假设您已经这样做了,因为编译器正在毫无怨言地通过这些行。在此修复之后,Window.cpp
编译得很好(但没有链接,因为我没有构建示例所依赖的库)。
相关文章:
- Boost Graph Library,修复节点大小
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- C++:关于使用 Stroustrup 示例移动构造函数/赋值的问题
- C++:引用引用,Stroustrup示例
- 关于Stroustrup C++书的自动和{}列表问题
- 如何从Stroustrup的C++书中解释这个正则表达式?
- C++:使用Stroustrup示例生成随机数?
- Stroustrup的C++书挑战赛,有人可以帮助我理解这段代码吗?
- 如何使用Stroustrup的Fltk Text类调用变量?
- 如何从TBB :: Flow :: Graph中删除/取消消息
- Boost Graph库,depth_first_search未在MSVC中调用finish_edge
- Bjarne Stroustrup PPP - 第 9 章 演练 4 - cout 枚举错误
- Stroustrup Ex.7, Chap.4 - C++ Syntax
- 代码在Visual C ++中无法按预期工作(来自bjarne stroustrup编程和原则书籍2n版本的示例)
- Bjarne Stroustrup Book - Vector and For loop - 将不起作用
- Bjarne Stroustrup在他的FAQ中"foundation libraries"是什么意思?
- 如何在Boost Graph库中的Grid_graph的边缘添加自定义属性
- 在Stroustrup的例子中,冒号在"return 1 : 2"中是什么意思?
- Stroustrup's Graph.h
- 如何在 Ubuntu 12.10 的 Netbeans 7.3 中使用 Stroustrup 的图形库(Simple_window.h、Graph.h、...)?