Last active
December 7, 2016 08:55
-
-
Save ilicmarko/a732bbb3b937657a72ba3b8c77c754e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Auto { | |
public: | |
int id; | |
}; | |
class Graditelj { | |
public: | |
virtual int napraviId() = 0; // Recimo neka dummy funkcija | |
}; | |
// Graditelj sad samo ime prepisane metode, nema Auto | |
class Konkretan : public Graditelj { | |
private: | |
public: | |
int napraviId(){ return 12334; } | |
}; | |
class Direktor { | |
protected: | |
Graditelj* graditelj; | |
public: | |
void postaviGraditelja(Graditelj* g) { | |
graditelj = g; | |
} | |
Auto* napraviAuto() { | |
Auto* tmpAuto = new Auto(); // Pravimo prazan auto bez "delova" | |
tmpAuto->id = graditelj->napraviId(); | |
return tmpAuto; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ovde je "problem" sto je polje
id
u ovom slucaju javno a ne bi trebaloresenje za to je da proglasimo klasu direktor kao prijateljsku za Auto