0

我试图在 Visual Studio 2013 中运行此处提供的示例代码http://dlib.net/bayes_net_ex.cpp.html,设置了所有库,但我在方法元素和元素 const 处遇到两个 c2244 错误。

这是错误报告

1>------ Build started: Project: bayesian, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>  bayesian.cpp
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\dlib\binary_search_tree\binary_search_tree_kernel_c.h(187): error C2244: 'dlib::binary_search_tree_kernel_c<bst_base>::element' : unable to match function definition to an existing declaration
1>          definition
1>          'const dlib::map_pair<bst_base::domain_type,bst_base::range_type> &dlib::binary_search_tree_kernel_c<bst_base>::element(void) const'
1>          existing declarations
1>          'dlib::map_pair<binary_search_tree_kernel_c<bst_base>::::domain_type,binary_search_tree_kernel_c<bst_base>::::range_type> &dlib::binary_search_tree_kernel_c<bst_base>::element(void)'
1>          'const dlib::map_pair<binary_search_tree_kernel_c<bst_base>::::domain_type,binary_search_tree_kernel_c<bst_base>::::range_type> &dlib::binary_search_tree_kernel_c<bst_base>::element(void) const'
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\dlib\binary_search_tree\binary_search_tree_kernel_c.h(205): error C2244: 'dlib::binary_search_tree_kernel_c<bst_base>::element' : unable to match function definition to an existing declaration
1>          definition
1>          'dlib::map_pair<bst_base::domain_type,bst_base::range_type> &dlib::binary_search_tree_kernel_c<bst_base>::element(void)'
1>          existing declarations
1>          'dlib::map_pair<binary_search_tree_kernel_c<bst_base>::::domain_type,binary_search_tree_kernel_c<bst_base>::::range_type> &dlib::binary_search_tree_kernel_c<bst_base>::element(void)'   
1>          'const dlib::map_pair<binary_search_tree_kernel_c<bst_base>::::domain_type,binary_search_tree_kernel_c<bst_base>::::range_type> &dlib::binary_search_tree_kernel_c<bst_base>::element(void) const'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我看不出这里有什么问题。

4

1 回答 1

0

这是 Visual Studio 2013 中的一个错误。您可以通过将 binary_search_tree_kernel_c.h 中的两个 element() 函数的定义从类外部移动到类内部来解决它。

于 2013-11-25T04:11:10.990 回答