Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string.h>
- using namespace std;
- class Student
- {
- int matricola;
- char *nume;
- int an;
- char specializare[50];
- public:
- int get_matricola()
- {
- return matricola;
- }
- void set_matricola(int matricola)
- {
- this->matricola=matricola;
- }
- char *get_nume()
- {
- return nume;
- }
- void set_nume(const char* nume)
- {
- this->nume=new char[strlen(nume)+1];
- strcpy(this->nume, nume);
- }
- int get_an()
- {
- return an;
- }
- void set_an(int an);
- char* get_specializare()
- {
- return specializare;
- }
- void set_specializare(char* specializare);
- void afiseaza();
- };
- void Student::set_an(int an)
- {
- this->an=an;
- }
- void Student::set_specializare(char* specializare)
- {
- strcpy(this->specializare, specializare);
- }
- void Student::afiseaza()
- {
- cout<<"Matricola:"<<matricola<<endl;
- cout<<"Nume:"<<nume<<endl;
- cout<<"An:"<<an<<endl;
- cout<<"Specializare:"<<specializare<<endl;
- }
- int main()
- {
- Student s;
- s.set_matricola(1000);
- s.set_nume("pop ion");
- s.set_an(2);
- s.set_specializare("cibernetica economica");
- s.afiseaza();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement