oop - Realization in C++ -


need in understanding "realization" relationship classes. can give me c++ example on this?

i browsed , got know that, class implementing interface example of realization. didn't better picture. how represent same using uml?

thanks

realization specifies contract between 2 or more types. 1 type (here interface imammals) defines contract , other type (cat, dog) promises carry out.

below code lazy example of realization...

#include<iostream> using namespace std;  class imammals{ public:     virtual void walk() = 0; };  class cats: public imammals { public:     void walk() {         cout<< "cat walking" << endl;     } };  class dogs: public imammals { public:     void walk(){         cout<< "dog walking" << endl;     } };  int main(void) {     cats acat;     dogs adog;     imammals *ptrmammals = null;      ptrmammals = &acat;     ptrmammals->walk();      ptrmammals = &adog;     ptrmammals->walk();      return 0; } 

using uml, realization represented dotted arrow points type two(cat,dog or contractor) class type 1 class(imammals or contractee). tip of arrow empty triangle.

                +-----------------+                 |      imammals   |                 |-----------------|                 |                 |     +---------|>|                 |<|--------+     |           +-----------------+          |     |                                        |     |                                        | +-----+-----+                            +-----+-----+ |    cat    |                            |    dog    | |-----------|                            |-----------| |           |                            |           | +-----------+                            +-----------+ 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -