Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <string>
- #include <vector>
- #include <cstring>
- #include <algorithm>
- using namespace std;
- class Student{
- private:
- char *nume;
- int varsta;
- int anStudiu;
- bool bursa;
- public:
- Student(const char *,int,int,bool);
- friend ostream& operator <<(ostream & f, Student & s);
- bool get_bursier();
- char* get_nume();
- int get_anstudiu();
- int get_varsta();
- };
- Student::Student(const char *nume, int varsta, int anStudiu, bool bursa)
- {
- if(nume!=NULL)
- {
- this->nume=new char[strlen(nume)+1];
- strcpy(this->nume,nume);
- }
- this->varsta=varsta;
- this->anStudiu=anStudiu;
- this->bursa=bursa;
- }
- ostream & operator <<(ostream & f, Student & s)
- {
- cout<<s.get_nume()<<" "<<s.get_varsta()<<" "<<s.get_anstudiu()<<" "<<s.get_bursier()<<endl;
- return f;
- }
- bool Student::get_bursier()
- {
- return this->bursa;
- }
- char* Student::get_nume()
- {
- return this->nume;
- }
- int Student::get_anstudiu()
- {
- return this->anStudiu;
- }
- int Student::get_varsta()
- {
- return this->varsta;
- }
- int main()
- {
- std::vector<Student> myvector;
- myvector.emplace_back(Student("Popa",20,2,1));
- myvector.emplace_back(Student("Ion",21,3,0));
- myvector.emplace_back(Student("Alin",21,1,1));
- myvector.emplace_back(Student("Elena",19,1,0));
- for_each(myvector.begin(),myvector.end(),[](Student & m){cout<<m;});
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement