Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename prop_name>
- class Property
- {
- public:
- void easifyEquation(const char* equation) {
- // property is maybe true, but not known
- // so don't easify the equation, do nothing!
- }
- };
- template<typename prop_type>
- class TrueProperty
- {
- prop_type prop_implementation;
- public:
- void easifyEquation(const char* equation) {
- prop_implementation.easifyEquation(equation);
- }
- };
- class IsPID {
- void easifyEquation(const char* equation) {}
- };
- class IsUFD{};
- class IsDedekind{};
- class BaseRing
- {
- public:
- Property<IsUFD> ufd;
- Property<IsDedekind> dedekind;
- Property<IsPID> pid;
- };
- class UFD : public BaseRing
- {
- public:
- TrueProperty<IsUFD> ufd;
- };
- class Dedekind : public BaseRing
- {
- public:
- TrueProperty<IsDedekind> dedekind;
- };
- class Both : public BaseRing
- {
- public:
- TrueProperty<IsUFD> ufd;
- TrueProperty<IsDedekind> dedekind;
- // shall have the isPID property implicitly
- };
- void do_experiments()
- {
- UFD ufd;
- Both both;
- /*
- Let's easify an equation
- */
- const char* equation;
- // both is a pid, since ufd and dedekind implies pid
- // thus, we can easify equations with the pid property
- both.pid.easifyEquation(equation);
- // the ufd is not (necessary) a PID
- // thus, easifying the equation like in PIDs shall not do anything.
- ufd.pid.easifyEquation(equation);
- }
- int main() {
- do_experiments();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement