You are on page 1of 5

ASSIGNMENT​ ​3

Name:​ ​Prit​ ​Raj

Roll​ ​No.​ ​:​ ​45​ ​(510814056)

Understanding​ ​(Exploring)​ ​Doxygen​ ​Tool

1.​ ​Firstly,​ ​write​ ​a​ ​C++/JAVA,​ ​C​ ​code​ ​in​ ​a​ ​directory​ ​which​ ​finds​ ​the​ ​largest​ ​string​ ​from​ ​an 
array​ ​of​ ​strings.

#include<iostream>

#include<string>

using​ ​namespace​ ​std;

/*!​ ​\mainpage​ ​Inheritance

​ ​*

​ ​*​ ​This​ ​project​ ​helps​ ​user​ ​to​ ​understand​ ​Inheritance​ ​and​ ​Vrtual​ ​Function

​ ​* 

​ ​*​ ​-​ ​\subpage​ ​Inheritance

​ ​*

​ ​*​ ​-​ ​\subpage​ ​Virtual​ ​Function

​ ​*

​ ​*/

/*!​ ​Short​ ​Description​ ​on​ ​the​ ​first​ ​line

​ ​ ​ ​ ​The​ ​class​ ​Base​ ​is​ ​used​ ​here​ ​to​ ​find​ ​the​ ​largest​ ​string​ ​among​ ​array​ ​of​ ​strings

​ ​ ​ ​ ​Created​ ​by​ ​Ishan

*/

class​ ​Base

​ ​ ​ ​ ​public:

​ ​ ​ ​ ​ ​ ​ ​ ​Base()
​ ​ ​ ​ ​ ​ ​ ​ ​{

​ ​ ​ ​ ​ ​ ​ ​ ​}

​ ​ ​ ​ ​ ​ ​ ​ ​/**

@return​ ​to​ ​find​ ​the​ ​largest​ ​string​ ​among​ ​array​ ​of​ ​strings

*/

​ ​ ​ ​ ​ ​ ​ ​ ​virtual​ ​void​ ​Find_Max(string​ ​str[],​ ​int​ ​n)

​ ​ ​ ​ ​ ​ ​ ​ ​{

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​int​ ​i,​ ​Max​ ​=​ ​-1,​ ​collect;

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​string​ ​temp;

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​for(i=0;​ ​i<n;​ ​i++)

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​{

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​collect​ ​=​ ​str[i].length();

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​if(collect​ ​>​ ​Max)

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​{

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​Max​ ​=​ ​collect;

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​temp​ ​=​ ​str[i];

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​}

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​}

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​cout​ ​<<​ ​"BASE​ ​=​ ​Largest​ ​String​ ​is​ ​"​ ​<<​ ​temp​ ​<<​ ​"​ ​->​ ​Length:​ ​"​ ​<<​ ​Max​ ​<<​ ​endl;

​ ​ ​ ​ ​ ​ ​ ​ ​}

};

class​ ​Derived:​ ​public​ ​Base

​ ​ ​ ​ ​public:

  /**
@return​ ​to​ ​find​ ​the​ ​largest​ ​string​ ​among​ ​array​ ​of​ ​strings

*/

​ ​ ​ ​ ​ ​ ​ ​ ​void​ ​Find_Max(string​ ​str[],​ ​int​ ​n)

​ ​ ​ ​ ​ ​ ​ ​ ​{

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​int​ ​i,​ ​Max​ ​=​ ​-1,​ ​collect;

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​string​ ​temp;

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​for(i=0;​ ​i<n;​ ​i++)

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​{

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​collect​ ​=​ ​str[i].length();

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​if(collect​ ​>​ ​Max)

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​{

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​Max​ ​=​ ​collect;

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​temp​ ​=​ ​str[i];

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​}

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​}

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​cout​ ​<<​ ​"CHILD​ ​=​ ​Largest​ ​String​ ​is​ ​"​ ​<<​ ​temp​ ​<<​ ​"​ ​->​ ​Length:​ ​"​ ​<<​ ​Max​ ​<<​ ​endl;

​ ​ ​ ​ ​ ​ ​ ​ ​}

};

int​ ​main()

string​ ​str[]​ ​=​ ​{"ABC",​ ​"DEFG",​ ​"SOFTWARE",​ ​"DOXYGEN"};

Base​ ​obj1;

Derived​ ​obj2;

cout​ ​<<​ ​"This​ ​is​ ​compile​ ​time​ ​binding"​ ​<<​ ​endl;


int​ ​length​ ​=​ ​sizeof(str)/sizeof(str[0]);

obj1.Find_Max(str,​ ​length);

cout​ ​<<​ ​"\nThis​ ​is​ ​run​ ​time​ ​binding"​ ​<<​ ​endl;

Base​ ​*obj3​ ​=​ ​&obj2;

obj3->Find_Max(str,​ ​length);

2)​ ​The​ ​comments​ ​are​ ​written​ ​according​ ​to​ ​the​ ​format​ ​of​ ​doxygen.

For​ ​example:

a)​​ ​/*!​ ​\mainpage

​ ​* 

​ ​*/

It​ ​can​ ​be​ ​used​ ​to​ ​write​ ​description​ ​or​ ​main​ ​page​ ​explanation.

b)​​ ​To​ ​create​ ​UML​ ​diagrams,​ ​follow​ ​the​ ​following​ ​steps​ ​in​ ​the​ ​terminal:

$​ ​doxygen​ ​-g

Then​ ​go​ ​to​ ​Doxyfile​ ​and​ ​make​ ​the​ ​following​ ​changes


HAVE_DOT​ ​=​ ​YES
UML_LOOK​ ​=​ ​YES

Output:

Configuration​ ​file​ ​`Doxyfile'​ ​created.


we​ ​have​ ​to​ ​edit​ ​the​ ​configuration​ ​file​ ​and​ ​enter

​ ​ ​doxygen​ ​Doxyfile

to​ ​create​ ​the​ ​documentation​ ​for​ ​my​ ​project

c)​​ ​Then​ ​run​ ​the​ ​following​ ​command​ ​in​ ​terminal

$​ ​doxygen​ ​Doxyfile

we​ ​will​ ​get​ ​html​ ​and​ ​latex​ ​files.​ ​We​ ​have​ ​to​ ​choose​ ​any​ ​one​ ​of​ ​them​ ​to​ ​see​ ​the​ ​documentation.

You might also like