Advertisement
Weper

return char

May 8th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. struct teszt
  7. {
  8.     int evszam;
  9.     char cim[25];
  10. };
  11.  
  12. class konyvesbolt
  13. {
  14. private:
  15.     int db;
  16.     teszt *konyv;
  17. public:
  18.     konyvesbolt();
  19.     ~konyvesbolt();
  20.     char Legoregebb();
  21. };
  22.  
  23. konyvesbolt::konyvesbolt()
  24. {
  25.     db = 3;
  26.     konyv = new teszt[db];
  27.     strcpy_s(konyv[0].cim, 25, "valami");
  28.     konyv[0].evszam = 2005;
  29.     strcpy_s(konyv[1].cim, 25, "valami2");
  30.     konyv[1].evszam = 2001;
  31.     strcpy_s(konyv[2].cim, 25, "valami3");
  32.     konyv[2].evszam = 2012;
  33.  
  34. }
  35.  
  36. konyvesbolt::~konyvesbolt()
  37. {
  38.     delete[]konyv;
  39.     konyv = 0;
  40.     db = 0;
  41. }
  42.  
  43. char konyvesbolt::Legoregebb()
  44. {
  45.     int min = konyv[0].evszam;
  46.     char temp[25];
  47.     for (int i = 0; i < db; i++)
  48.     {
  49.         if (konyv[i].evszam < min)
  50.         {
  51.             min = konyv[i].evszam;
  52.             strcpy_s(temp, 25, konyv[i].cim);
  53.         }
  54.     }
  55.     return temp[25];
  56. }
  57.  
  58.  
  59. int main()
  60. {
  61.     konyvesbolt a;
  62.     char temp[25];
  63.     temp[25] = a.Legoregebb();
  64.    
  65.     cout << temp[25];
  66.  
  67.     _getch();
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement