- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
以下代码是应用程序的一小部分。对于该应用程序,我需要使用 in_box.get_string()。 in_box的声明和定义在this中GUI.h 和 GUI.cpp 文件中的地址。
对于整数,它工作正常。也就是说,如果我使用 in_box.get_int(),它会获取输入到 in_box 中的数字,并将该数字作为 integer
返回。但问题是,正如预期的那样,它不适用于 strings
。当使用字符串时,我会出错!
例如在下面的代码中我使用了一个string
s。
#include <GUI.h>
#include <iostream>
using namespace Graph_lib;
class Calculator : public Window {
public:
Calculator(Point, int, int, const string&);
private:
//Widgets
Button show_button;
In_box enter_box;
void show() { getstr(); cout <<s; }
void getstr() {
s = enter_box.get_string();
}
static void cb_show(Address, Address pw) { reference_to<Calculator>(pw).show(); }
string s;
};
//---------------------------------------------------------------------
Calculator::Calculator(Point xy, int w, int h, const string& title):
Window(xy, w, h, title),
show_button(Point(x_max()-110, 440), 90, 35, "Show", cb_show),
enter_box(Point(x_max()-400, 158), 245, 40, "Enter"){
attach(enter_box);
attach(show_button);
}
int main()
{
Calculator cal(Point(100,100), 600, 500, "Calculator");
return gui_main();
}
有 8 个警告和两个错误。错误是这些:
Error 9 error LNK2019: unresolved external symbol "public: class std::basic_string,class std::allocator > __thiscall Graph_lib::In_box::get_string(void)" (?get_string@In_box@Graph_lib@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "private: void __thiscall Calculator::getstr(void)" (?getstr@Calculator@@AAEXXZ) C:\Users\ME\documents\visual studio 2012\Projects\test_3\test_3\test_3.obj Error 10 error LNK1120: 1 unresolved externals C:\Users\ME\documents\visual studio 2012\Projects\test_3\Debug\test_3.exe
错误表明,这是一个链接器问题,但我的链接器输入的文件列表如下,到目前为止(几乎)工作正常。
fltkd.lib
wsock32.lib
comctl32.lib
fltkjpegd.lib
fltkimagesd.lib
我的编译器是 MS VS 2012。机器是 Win 7。
请问有人知道如何解决这个问题吗?
最佳答案
如果您在调试和 Release模式下编译了 FLTK,请确保您具有正确的链接器依赖项:您为调试列出的文件,以及 fltk.lib、wsock32.lib、comctl32.lib、fltkjpegd.lib 和 fltkimages.lib 用于 Release(注意名称末尾没有“d” ).
其次,即使我不认为它会导致链接器错误(但会导致其他奇怪的问题),请确保您已将所有 Stroustrup 图形库文件包含在您的 Visual Studio 项目中:fltk.h , Graph.h, GUI.h, Point.h, Simple_window.h, < strong>std_lib_facilities.h、Window.h、Graph.cpp、GUI.cpp 和Window.cpp.
关于c++ - 如何使用 FLTK in-box.get_string(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28404380/
所以我有这门课它应该包含我的窗口和我将用作回调的所有函数。 #include #include #include #include #include #include #include
我正在制作一个简单的 FLTK 应用程序(在 Linux 中),它需要在 FL_Window 中显示 PNG 图像。下一段代码: Fl_PNG_Image* pngImg; Fl_Box* boxIm
C++ fltk:我有一个带有 in_box 和 out_box 的窗口,我该如何制作它以便用户可以在 in_box 中键入内容并按回车键,然后继续事件的其余部分。现在窗口刚刚出现并消失了。 Wind
我基本上有一个带有收件箱和输入按钮的窗口。我怎样才能使窗口保持打开和绘制状态,直到用户输入 in_box 并点击回车按钮。 Window w(Point(100,100),200,200, "Cate
我在 FLTK 应用程序 (C++) 上工作,我必须创建要在 Fl_Browser 中设置的名称。基本上这个结构接收一个带有 的“const char*” 浏览器->add("my string.."
我刚刚加入了这个令人惊叹的社区,以获得一个非常烦人的问题的答案。我正在尝试使用 FLTK 创建一个五连胜游戏。目前我刚刚完成它的笨版本井字游戏。所以我的问题是:我用许多按钮创建了一个板。对于井字游戏,
在 FLTK 中,有没有办法让用户在运行时通过拖动小部件框的边框来调整小部件的大小?我的意思是,例如,以我们通常在任何操作系统中调整窗口大小的方式调整 Fl_Text_Display 或 Fl_Box
首先,我回顾了示例test/threads.cxx;但这并不是我正在寻找的用例,因为示例线程函数可以访问 FLTK 函数。 我有一个 libssh2 库函数(我写的,但希望它不依赖于 FLTK),具有
例如,我有 5 个选择组件 Fl_Choice* mySideChoice; mySideChoice = new Fl_Choice(aX, aY, aWidth, aHeight, "Side")
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我正在尝试使用 FLTK 在 C++ 程序中绘制 xpm 文件。 这是代码 #include #include #include "image.xpm" #include #include #
我正在使用 FLTK要创建 GUI,我必须在屏幕上绘制一些多边形(形状)。 来自他们的 fl_complex_polygon 文档: Start and end drawing a convex fi
问题是:画一个圆角的盒子。定义一个类Box,由四条线和四条弧组成。所以我为该练习编写了以下代码: #include Simple_window win(Point(100,100), 600,400
我正在使用 FLTK。我有一个带有各种按钮的窗口,用户可以单击它们来执行某些操作。在我的 int main() 中,我有一个 switch 语句来处理所有这些。当用户单击退出时,switch 语句设置
我是 C++ 的初学者,正在学习 Stroustrup 的 - Programming Principles and Practice using C++。第12章介绍了显示模型,任务是在系统上安装并
我有一个带有弹出菜单的单线程 FLTK 应用程序,使用 Fluid 创建。我有一个子类 Fl_Gl_Window 并实现了一个 handle() 方法。 handle() 方法调用一个函数,该函数在右
我在iOS Mojave 10.14.6上使用FLTK库(版本1.3.5):我编写了这个简单程序 #include #include #include #include #include #
我正在尝试在 fltk 中创建一个程序,我遵循了这个例子 #include #include #include int main(int argc, char **argv) { Fl_Wi
我正在使用 Fltk 渲染 openGL 图形。目前我正在调试一个由堆排序函数排序的全局数组。我的目的是在堆排序函数中的每次元素交换之后查看元素的图形交换。但我不想每次在交换并在断点处等待后需要重绘时
我有一个在 Visual Studio 中完成的 FLTK 项目,它编译得非常好。但是当我使用 g++ 编译它时,它给了我这个错误: Undefined f
我是一名优秀的程序员,十分优秀!