Problem with Polygon in Stroustrup's PPP book

Hi guys,

I read Programming Principles and Practice using C++, Stroustrup's book. In chapter 12 and in page 441 (first example) there is this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// 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
}

//------------------------------------------------------------------------------ 



When I run the code I get 13 errors which must of them are about the Polygon identifier.
The problem in that code has to do with Polygon poly; and the rest of the using of it. For example first error is: Error C2872: 'Polygon' : ambiguous symbol

Why my compiler doesn't know that Polygon please?
No reply!?
http://msdn.microsoft.com/en-us/library/t57wswcs.aspx

We can't help without the other header files... maybe you copied them wrong. Read the article, it gives a few suggestions.
OK now I used this, Graph_lib::Polygon poly; instead of Polygon poly; but again get another errors. One of them is this:

Error 9 error LNK2001: unresolved external symbol "protected: virtual void __thiscall Graph_lib::Window::draw(void)" (?draw@Window@Graph_lib@@MAEXXZ) C:\Users\CS\documents\visual studio 2012\Projects\Win32Project1\Win32Project1\Win32Project1.obj
I also inputted the graph_lib.lib library into linker input but this time faced this error:

Error 1 error LNK1104: cannot open file 'graph_lib.lib' C:\Users\CS\documents\visual studio 2012\Projects\Win32Project1\Win32Project1\LINK

you guys can read the detailed version of this problem here: http://stackoverflow.com/questions/21063872/fltk-version-1-3-2-visual-studio-2012-and-the-first-example-of-stroustrups-ppp
Last edited on
Topic archived. No new replies allowed.