Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include<string.h>
  3.  
  4. using namespace std;
  5.  
  6. class Student
  7. {
  8. int matricola;
  9. char *nume;
  10. int an;
  11. char specializare[50];
  12.  
  13. public:
  14. int get_matricola()
  15. {
  16. return matricola;
  17. }
  18. void set_matricola(int matricola)
  19. {
  20. this->matricola=matricola;
  21. }
  22.  
  23. char *get_nume()
  24. {
  25. return nume;
  26. }
  27. void set_nume(const char* nume)
  28. {
  29. this->nume=new char[strlen(nume)+1];
  30. strcpy(this->nume, nume);
  31. }
  32.  
  33. int get_an()
  34. {
  35. return an;
  36. }
  37. void set_an(int an);
  38.  
  39. char* get_specializare()
  40. {
  41. return specializare;
  42. }
  43. void set_specializare(char* specializare);
  44.  
  45. void afiseaza();
  46.  
  47. };
  48. void Student::set_an(int an)
  49. {
  50. this->an=an;
  51. }
  52.  
  53. void Student::set_specializare(char* specializare)
  54. {
  55.  
  56. strcpy(this->specializare, specializare);
  57. }
  58. void Student::afiseaza()
  59. {
  60. cout<<"Matricola:"<<matricola<<endl;
  61. cout<<"Nume:"<<nume<<endl;
  62. cout<<"An:"<<an<<endl;
  63. cout<<"Specializare:"<<specializare<<endl;
  64. }
  65.  
  66. int main()
  67. {
  68. Student s;
  69. s.set_matricola(1000);
  70. s.set_nume("pop ion");
  71. s.set_an(2);
  72. s.set_specializare("cibernetica economica");
  73. s.afiseaza();
  74. return 0;
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement