Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- struct Data {
- int iValue;
- float fValue;
- std::string sValue;
- };
- struct Parameter {
- std::vector<Data> data;
- };
- void func1(const Parameter& p) {
- for (int i = 0; i < p.data.size(); ++i)
- std::cout << "func1 param " << i << ": " << p.data[i].iValue << ", "
- << p.data[i].fValue << ", " << p.data[i].sValue << std::endl;
- }
- void func2(const Parameter& p) {
- for (int i = 0; i < p.data.size(); ++i)
- std::cout << "func2 param " << i << ": " << p.data[i].iValue << ", "
- << p.data[i].fValue << ", " << p.data[i].sValue << std::endl;
- }
- void func3(const Parameter& p) {
- for (int i = 0; i < p.data.size(); ++i)
- std::cout << "func3 param " << i << ": " << p.data[i].iValue << ", "
- << p.data[i].fValue << ", " << p.data[i].sValue << std::endl;
- }
- void func4(const Parameter& p) {
- for (int i = 0; i < p.data.size(); ++i)
- std::cout << "func4 param " << i << ": " << p.data[i].iValue << ", "
- << p.data[i].fValue << ", " << p.data[i].sValue << std::endl;
- }
- int main(int argc, char** argv)
- {
- void(*pFunctions[4])(const Parameter& p) = { func1, func2, func3, func4 };
- Parameter p;
- p.data.push_back({ 5, 0, "" });
- p.data.push_back({ 0, 3.14, "" });
- p.data.push_back({ 0, 0, "Merkkijono" });
- (*pFunctions[0])(p);
- (*pFunctions[1])(p);
- p.data[1] = { 0, 3.14 * 3, "" };
- p.data.push_back({ 666, 6.66, "666" });
- (*pFunctions[2])(p);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement