Advertisement
globalbus

Untitled

Nov 30th, 2013
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. class student
  2. {
  3.     public:
  4.     int indeks;
  5.     string imie, nazwisko;
  6.     const string values[] = {"indeks", "imie", "nazwisko"};
  7.         const void* pointers[] = {&indeks, &imie, &nazwisko};
  8.     void* getValue(string a)
  9.     {
  10.         int n = 3;
  11.         for (int x = 0; x < n; x++)
  12.             if (a == values[x])
  13.                 return pointers[x];
  14.     }
  15. };
  16.  
  17.  
  18. int main(int argc, char** argv)
  19. {
  20.     student lukasz;
  21.     lukasz.imie = "LUKAsz";
  22.     string* s = (string *) lukasz.getValue("imie");
  23.     cout << *s;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement