我的程序中有一个结构
struct secret_structure{
string a;
string b;
void *c;
};
我有一个这样的结构列表
std::map<string name, secret_structure> my_map
我必须编写一个函数,通过将结构映射到名称来返回结构。
get_from_map(string name, secret_structure * struct) //Kind of function
我有以下选择:
在 get_from_map 函数中传递一个 secret_structure 的指针。get_from_map 填充结构。我不想这样做,因为结构会暴露。
我可以有不同的函数来从结构中返回不同的值。这里结构不会暴露,但看起来不干净。
你能帮我做任何其他的选择吗,这样结构本身就不会暴露。