Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>//cin&cout.
- #include <string>//Лень плясать с бубном вокруг массивов char. Поэтому юзаю стринги!
- #include <conio.h>//Для getch();
- using namespace std;
- int Studentcount=0;
- class Student{
- string *surname, *name, *midname, *groupname;
- unsigned short *birthyear;
- public:
- string *get_surname(){
- return surname;
- }
- void set_surname(string s){
- *surname=s;
- }
- string *get_name(){
- return name;
- }
- void set_name(string s){
- *name=s;
- }
- string *get_midname(){
- return midname;
- }
- void set_midname(string s){
- *midname=s;
- }
- unsigned short *get_birthyear(){
- return birthyear;
- }
- void set_birthyear(unsigned short x){
- *birthyear=x;
- }
- string *get_groupname(){
- return groupname;
- }
- void set_groupname(string s){
- *groupname=s;
- }
- static Student *get_new(){
- return new Student;
- }
- void remove(){
- this->~Student();
- }
- private:
- Student(string s1="Default_value", string s2="Default_value", string s3="Default_value", unsigned short i4=0, string s4="Default_value"){
- cout<<"\nВход в функцию Student::Student();\n";
- cout<<"В ОЗУ содержатся "<<++Studentcount<<" элементов\n";
- name=new string;
- *name=s1;
- surname=new string;
- *surname=s2;
- midname=new string;
- *midname=s3;
- birthyear=new unsigned short;
- *birthyear=i4;
- groupname=new string;
- *groupname=s4;
- }
- ~Student(){
- cout<<"\nВход в функцию Student::~Student();\n";
- cout<<"В ОЗУ содержатся "<<--Studentcount<<" элементов\n";
- delete surname;
- delete name;
- delete midname;
- delete groupname;
- delete birthyear;
- }
- public:
- Student(const Student& t){
- *surname=*(t.surname);
- *name=*(t.name);
- *midname=*(t.midname);
- *birthyear=*(t.birthyear);
- *groupname=*(t.groupname);
- }
- };
- Student *test(Student *s){
- return s;
- }
- int main(int argc, char **argv){
- setlocale(LC_ALL, "rus");
- cout<<"Beginning of int main function"<<endl;
- Student *one=Student::get_new();
- one->set_name("Ivan");
- one->set_surname("Ivanov");
- one->set_midname("Ivanovych");
- one->set_birthyear(1970);
- one->set_groupname("vkb21");
- Student *mas[100];
- for(int i=0;i<100;i++){
- mas[i]=Student::get_new();
- }
- for(int i=99;i>=0;i--){
- mas[i]->remove();
- }
- one->remove();
- cout<<"Ending of int main function"<<endl;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment