Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Momche {
- private:
- char ime[101];
- char prezime[101];
- int godini;
- public:
- Momche() { // empty constructor
- }
- Momche(const char *i, const char *p, int g) { // constructor with
- strcpy(ime, i);
- strcpy(prezime, p);
- godini = g;
- }
- ~Momche() {
- }
- void pecati() {
- cout << "Momche: " << ime << " " << prezime << " " << godini << endl;
- }
- int get_godini() const {
- return godini;
- }
- };
- class Devojche {
- private:
- char ime[101];
- char prezime[101];
- int godini;
- public:
- Devojche() {
- }
- Devojche(const char *i, const char *p, int g) {
- strcpy(ime, i);
- strcpy(prezime, p);
- godini = g;
- }
- ~Devojche() {
- }
- void pecati() {
- cout << "Devojche: " << ime << " " << prezime << " " << godini << endl;
- }
- int get_godini() const {
- return godini;
- }
- };
- class Sredba {
- private:
- Momche m;
- Devojche d;
- public:
- Sredba() {
- }
- Sredba(Momche _m, Devojche _d) {
- m = _m;
- d = _d;
- }
- ~Sredba() {
- }
- void print() {
- m.pecati();
- d.pecati();
- }
- void daliSiOdgovaraat() {
- int razlika = abs(m.get_godini() - d.get_godini());
- if(razlika <= 5) {
- cout << "Si odgovaraat" << endl;
- }
- else {
- cout << "Ne si odgovaraat" << endl;
- }
- }
- };
- int main() {
- Momche m("a", "b", 27);
- Devojche d("q", "w", 20);
- Sredba s(m, d);
- s.daliSiOdgovaraat();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement