Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class student
- {
- public:
- int indeks;
- string imie, nazwisko;
- const string values[] = {"indeks", "imie", "nazwisko"};
- const void* pointers[] = {&indeks, &imie, &nazwisko};
- void* getValue(string a)
- {
- int n = 3;
- for (int x = 0; x < n; x++)
- if (a == values[x])
- return pointers[x];
- }
- };
- int main(int argc, char** argv)
- {
- student lukasz;
- lukasz.imie = "LUKAsz";
- string* s = (string *) lukasz.getValue("imie");
- cout << *s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement