Results 1 to 3 of 3
Thread: ++
Hybrid View
-
10th October 2010 14:04 #1
++
:
- "" , ;
- - () - (), ;
- ;
- Set() ;
- Print() ;
- .
:
---------------------------------------------------------------------------
- name, age, number, : GetName(), GetAge(), GetNumber();
- / ;
- , ;
- : , , , ;
- : , . , , ;
, , ? "Set()" , ? , , , , .
:
#include<iostream>
#include
// - People
class People
{public:
People(char * = , char * = , char * = , );
void PrintPeople() const;
~People();
private:
char * name;
char * egn;
};
// People
People::People(char *str, char *num)
{name = new char[strlen(str)+1];
strcpy(name, str);
egn = new char[11];
strcpy(egn, num);
}
// PrintPeople
void People::PrintPeople() const
{cout << Ime: << name << endl;
cout << EGN: << egn << endl;
}
// People
People::~People()
{cout << ~People(): << endl;
delete name;
delete egn;
}
// Student
class Student : People
{public:
Student(char * = , char * = , long = 0, double = 0);
void PrintStudent() const;
~Student()
{cout << ~Student(): << endl;
}
private:
long facnom;
double usp;
};
// Student
Student::Student(char *str, char * num, long facn,
double u) : People(str, num)
{facnom = facn;
usp = u;
}
// PrintStudent
void Student::PrintStudent() const
{PrintPeople();
cout << Fac. nomer: << facnom << endl;
cout << Uspeh: << usp << endl;
}
// PStudent
class PStudent : public Student
{public:
PStudent(char * = , char * = , long = 0,
double = 0, double = 0);
~PStudent()
{cout << ~PStudent() \n;
}
void PrintPStudent() const;
protected:
double tax;
};
// PStudent
PStudent::PStudent(char *str, char *num, long facn,
double u, double t) : Student(str, num, facn, u)
{tax = t;
}
// PrintPStudent
void PStudent::PrintPStudent() const
{PrintStudent();
cout << Tax: << tax << endl;
}
void main()
{People pe;
pe.PrintPeople();
PStudent PStud(Ivan Ivanov, 8206123422″, 42444, 6.0, 4567);
PStud.PrintPStudent();
}
-
10th October 2010 14:34 #2
:
1. Print(), PrintPStudent()/PrintStudent() .., , . , Print(). , Print()- , ::. , Student::Print() :
2. copy-constructor operator =" ( , ; - ).Code:// Print Student void Student::Print() const {People::Print(); ...
3. Set(). , , Set - , ( tax") ѝ . , , " (tax PStudent, facnom usp Student ..), - , - Set - . - !, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
10th October 2010 14:58 #3




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in