Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cmath>
- using namespace std;
- class Momche{
- private:
- char ime[20];
- char prezime[20];
- int godini;
- public:
- Momche(char *ime,char *prezime, int godini){
- strcpy(this->ime,ime);
- strcpy(this->prezime,prezime);
- this->godini=godini;
- }
- Momche(const Momche &m){
- strcpy(this->ime,m.ime);
- strcpy(this->prezime,m.prezime);
- this->godini=m.godini;
- }
- void pecati(){
- cout<<"Momche: "<<"Ime"<<" "<<"prezime"<<", "<<"godini"<<endl;
- }
- int getGodini()
- {
- return godini;
- }
- ~Momche (){}
- };
- class Devojche{
- private:
- char ime[20];
- char prezime[20];
- int godini;
- public:
- Devojche(char *ime,char *prezime, int godini){
- strcpy(this->ime,ime);
- strcpy(this->prezime,prezime);
- this->godini=godini;
- }
- Devojche(const Devojche &d){
- strcpy(this->ime,d.ime);
- strcpy(this->prezime,d.prezime);
- this->godini=d.godini;
- }
- void pecati(){
- cout<<"Devojche: "<<"Ime"<<" "<<"prezime"<<", "<<"godini"<<endl;
- }
- int getGodini(){
- return godini;
- }
- ~Devojche (){}
- };
- class Sredba{
- private:
- Momche momche;
- Devojche devojche;
- public:
- Sredba(const Momche m, const Devojche d);
- void pecati(){
- cout<<"Sredba:"<<endl;
- momche.pecati();
- devojche.pecati();
- }
- void daliSiOdgovaraat(){
- if(abs(momche.getGodini()-devojche.getGodini())<=5){
- cout<<"Si odgovaraat"<<endl;
- }
- else{
- cout<<"Ne si odgovaraat "<<endl ;
- }
- }
- };
- int main() {
- int godini;
- char ime[20], prezime[20];
- cout << "Informacii za momche: " << endl;
- cout << "Ime: ";
- cin >> ime;
- cout << "Prezime: ";
- cin >> prezime;
- cout << "Godini: ";
- cin >> godini;
- Momche m(ime, prezime, godini);
- Momche momche(m);
- cout << "Informacii za Devojche: " << endl;
- cout << "Ime: ";
- cin >> ime;
- cout << "Prezime: ";
- cin >> prezime;
- cout << "Godini: ";
- cin >> godini;
- Devojche d(ime, prezime,godini);
- Devojche devojche(d);
- Sredba s(momche, devojche);
- s.pecati();
- s.daliSiOdgovaraat();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement