Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable: 4996)
- #include <iostream>
- #include <conio.h>
- #include<string.h>
- using namespace std;
- class Persoana {
- public:
- char nume[20];
- int varsta;
- Persoana(char nume[20], int varsta) {
- strcpy(this->nume, nume);
- this->varsta = varsta;
- cout << "Constructor class: Pesoana" << endl;
- }
- ~Persoana() {
- }
- char* getNume() {
- return nume;
- }
- int getVarsta() {
- return varsta;
- }
- void Prints() {
- cout << getNume() << endl << getVarsta();
- }
- char* setNume(char nume[20]) {
- strcpy(this->nume, nume);
- return nume;
- }
- int setVarsta(int varsta) {
- this->varsta = varsta;
- return varsta;
- }
- };
- class Student:public Persoana {
- public:
- char facultate[20];
- Student(char facultate[20],char nume[20],int varsta):Persoana(nume,varsta) {
- strcpy(this->facultate, facultate);
- cout << "Costructor class: Student"<<endl;
- }
- ~Student() {
- };
- char* getFacultate() {
- return facultate;
- }
- void Printf() {
- cout << getNume() << endl << getVarsta() << endl << getFacultate() << endl;
- }
- char* setFacultate(char facultate[20]) {
- strcpy(this->facultate,facultate);
- return facultate;
- }
- };
- int main() {
- char a[20] = "Mihai";
- char s[20] = "UCV";
- char c[20] = "eo";
- char n[20] = "sadad";
- Student v(s,a,23);
- v.Printf();
- v.setVarsta(12);
- v.Printf();
- v.setNume(c);
- cout << endl;
- v.Printf();
- cout << endl;
- v.setFacultate(n);
- v.Printf();
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement