尝试编译Stroustrup GUI钻取时出错(FLTK,错误c2039)

时间:2014-06-14 05:14:10

标签: c++

到目前为止,我已成功安装FLTK,运行演示,并成功运行Stroustrups书附录D中的测试。问题在于,当我尝试编写快速程序时,

#include <FL/FL.h>
#include<FL/Fl_Box.h>
#include<FL/Fl_Window.h>
#include<Graph.h>
#include<Simple_window.h>
#include<Point.h>
#include<Window.h>

using namespace Graph_lib;

int main() {
    Point tl(100,100);
    Simple_window Mywindow(tl,600,400,"Canvas");
}

我收到以下错误:

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\window.h(17): error C2039: 'Vector' : is not a member of 'std'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\window.h(17): error C2868: 'Vector' : illegal syntax for using-declaration; expected qualified-name

似乎有人在其中一个标头文件中写了#define vector Vector,因此using namespace std:vector变为using namespace std::Vector,这会产生错误。我自己尝试编辑头文件,但我没有权限,也无法保存任何更改。我该怎么做才能解决这个问题?

编辑:

这是请求的标头。我没有从他网站上的链接页面下载它,我是以zip文件的形式从第一版登陆页面下载的。

之前,我用链接到标题替换了标题,我收到了一个新错误:

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\graph.h(9): fatal error C1083: Cannot open include file: 'fltk.h': No such file or directory

//
// This is a GUI support code to the chapters 12-16 of the book
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//

#ifndef WINDOW_GUARD
#define WINDOW_GUARD

#include <string>
#include <vector>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include "Point.h"

using std::string;
using std::vector;

namespace Graph_lib
{
    class Shape;   // "forward declare" Shape
    class Widget;

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

    class Window : public Fl_Window { 
    public:
        // let the system pick the location:
        Window(int w, int h, const string& title);
        // top left corner in xy
        Window(Point xy, int w, int h, const string& title);    

        virtual ~Window() { }

        int x_max() const { return w; }
        int y_max() const { return h; }

        void resize(int ww, int hh) { w=ww, h=hh; size(ww,hh); }

        void set_label(const string& s) { copy_label(s.c_str()); }

        void attach(Shape& s) { shapes.push_back(&s); }
        void attach(Widget&);

        void detach(Shape& s);     // remove s from shapes 
        void detach(Widget& w);    // remove w from window (deactivates callbacks)

        void put_on_top(Shape& p); // put p on top of other shapes

    protected:
        void draw();

    private:
        vector<Shape*> shapes;     // shapes attached to window
        int w,h;                   // window size

        void init();
    };

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

           int gui_main(); // invoke GUI library's main event loop
    inline int x_max() { return Fl::w(); } // width of screen in pixels
    inline int y_max() { return Fl::h(); } // height of screen in pixels

} // of namespace Graph_lib

#endif // WINDOW_GUARD

0 个答案:

没有答案