我有一个结构,例如
struct Test
{
std::string a;
std::string b;
std::string c;
};
在项目的另一部分中,我想将值分配给结构中的一个或三个值(我想对其进行编辑。)>
可以做这样的事情:
void foo (std::string newValue, std::string nameOfStructMember) { for(auto & it : test) //in another part of project exist std::vector<Test> test; { it.nameOfStructMember= newValue; } }
例如在
main.cpp
中:
foo("This is my new value", "a");
我有一个结构,例如struct Test {std :: string a; std :: string b; std :: string c; };在项目的另一部分中,我想将值分配给结构中的一个或三个值(我想...
似乎您的意思是以下内容