问题描述
所以我正在试验模板,可能我在某处遇到了语法问题。我正在尝试编写一个类,它采用所选项目的向量,将它们的属性转换为布尔数组,然后生成代表整个选择状态的对象> 该对象被发送到 UI 视图并显示在上下文中带有三态复选框的菜单。我知道如何用漫长而艰难的方式来写这个,但我想避免代码重复,所以我决定使用模板。问题是我无法将成员函数传递给另一个成员函数。我收到编译错误 C3867 非标准语法;使用“&”创建指向成员的指针。
首先:对不起,如果它是重复的。第二:对不起,这个例子太长了,但我不知道我的错误在哪里。
#include <array>
#include <vector>
#include "Item.h"
enum class CheckState {unchecked,checked,partially_checked}; //the state of the context menu checkBoxes
struct CheckBoxModels //this is the final product we want to get
{
std::array<CheckState,10> general;
std::array<CheckState,6> surface;
std::array<CheckState,7> other;
};
class CheckModelGenerator{ //this class has to generate the chechBoxModel by taking a vector of pointers to the selected Items;
std::array<bool,10> getGeneralStatus(const Item& item); //each of these kNows how to get a specific list of properties from an item
std::array<bool,6> getSurfaceStatus(const Item& item); //and represent it with boolean
std::array<bool,7> getSomeOtherStatus(const Item& item);//depending on whether they exist or not;
template<int Size> //using this to call ANY of the functions above
using getAnyStatus = std::array<bool,Size>(CheckModelGenerator::*) (const Item& item);
template<int size> //a member function that converts the bool arrays to CheckState arrays,by iterrating trough the selected items
std::array<CheckState,size> getCheckStateFromAnyStatus(const std::vector<Item*>& selectedItems,getAnyStatus<size> getStatus);
public:
CheckBoxModels getAllCheckBoxModels(std::vector<Item*>& selectedItems) // this here creates the final product;
{
CheckBoxModels models;
models.general = getCheckStateFromAnyStatus(selectedItems,getGeneralStatus); //I'm having problem actually calling those template functions!
models.surface = getCheckStateFromAnyStatus(selectedItems,getSurfaceStatus);
models.other = getCheckStateFromAnyStatus(selectedItems,getSomeOtherStatus);
return models;
}
};
解决方法
好吧,您确实缺少 SELECT * FROM dataset.target2
EXCEPT
SELECT * FROM dataset.target
并且名称必须加上类名。试试这个:
&