fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <sstream>
  4.  
  5. class eigenerTyp
  6. {
  7. private:
  8. std::string Name;
  9. float a;
  10. float b;
  11. float c;
  12.  
  13. public:
  14.  
  15. eigenerTyp(std::string Name, float a, float b, float c):
  16. Name(Name), a(a), b(b), c(c) { }
  17. float GetValue() const {return c; };
  18. std::string GetName() const {return Name;}
  19. };
  20.  
  21.  
  22. std::string GetVariableName(eigenerTyp eigenVector[], int arraySize)
  23. {
  24. std::ostringstream namestream;
  25.  
  26. for(int i=0; i<arraySize;i++)
  27. {
  28. namestream << eigenVector[i].GetValue();
  29. }
  30.  
  31. return namestream.str();
  32. }
  33.  
  34. int main()
  35. {
  36. eigenerTyp var1("baum",3.0,6.0,7.0);
  37. eigenerTyp var2("blume",1.0,8.0,7.4);
  38.  
  39. eigenerTyp eigenVector[]={var1,var2};
  40.  
  41. std::cout << eigenVector[0].GetValue(); //writes value of c
  42.  
  43. std::cout << GetVariableName(eigenVector,2); //writes value of a
  44. }
  45.  
Success #stdin #stdout 0s 2988KB
stdin
Standard input is empty
stdout
777.4