我阅读了 Stroustrup 的《使用 C++ 进行编程原理和实践》一书。在第12章和第441页中有这样的代码:
//
// This is example code from Chapter 12.3 "A first example" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//
#include "Simple_window.h" // get access to our window library
#include "Graph.h" // get access to our graphics library facilities
//------------------------------------------------------------------------------
int main()
{
using namespace Graph_lib; // our graphics facilities are in Graph_lib
Point tl(100,100); // to become top left corner of window
Simple_window win(tl,600,400,"Canvas"); // make a simple window
Polygon poly; // make a shape (a polygon)
poly.add(Point(300,200)); // add a point
poly.add(Point(350,100)); // add another point
poly.add(Point(400,200)); // add a third point
poly.set_color(Color::red); // adjust properties of poly
win.attach (poly); // connect poly to the window
win.wait_for_button(); // give control to the display engine
}
//------------------------------------------------------------------------------
当我运行代码时,我收到 13 个错误,其中一定与Polygon标识符。例如第一个错误是:错误 C2872:“多边形”:不明确的符号
为什么我的编译器不知道这一点Polygon please?
如果符号不明确,则尝试使用其限定名称:
Graph_lib::Polygon poly;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)