我试图在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 ==========
我无法看到这里的错误。
答案 0 :(得分:0)
这是visual studio 2013中的一个错误。您可以通过将binary_search_tree_kernel_c.h中的两个element()函数的定义从类外部移动到类内部来解决它。