Advertisement
frentzy

CLase ex2. Public+Private

Jul 8th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. class persoana
  5. {
  6. public:
  7. char pren[20];
  8. int v;
  9. void Atribuie_nume(char s[20])
  10. {
  11. strcpy(nume,s);
  12. }
  13. void Afiseaza()
  14. {
  15. Afiseaza_nume();
  16. cout<<" "<<pren;
  17. }
  18.  
  19. int Varsta()
  20. {
  21. return v;
  22. }
  23. private:
  24. char nume[20];
  25. void Afiseaza_nume()
  26. {
  27. cout<<nume;
  28. }
  29. };
  30. persoana pers;
  31.  
  32. int main()
  33. {
  34.  
  35. pers.Atribuie_nume("Testulescu");
  36. cout<<"Prenume: ";
  37. cin>>pers.pren;
  38. cout<<"Varsta: ";
  39. cin>>pers.v;
  40. pers.Afiseaza();
  41.  
  42. cout<<" \nVarsta: ";
  43. cout<<pers.Varsta();
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement