C++ : New Design with program example in hindi explanation , what is new design in c++ language

what is new design in c++ language , C++ : New Design with program example in hindi explanation :-
जिसे की c++ language मे , किसी प्रोग्राम को execute करने के लिए दो अलग अलग file को execute किया जाता है बाद मे इसे merge किये जाता है | अगर यूजर द्वारा किसी एक file को modify किया जाता है तब इसे recompile किया जाता है |और इसे पहले compile प्रोसेस मे मिली दूसरी file से merge किया जाता है | इस्लोये c++ लंगौगे एक बड़े प्रोग्राम को handle करने के लिए उपयुक्त language है | लेकिन c++ language इसके अलवा कई और भी facility भी देता है |
जैसे UNIX और Linux सिस्टम मे , track() किसी file को track करता है जो प्रोग्राम की dependency और last मॉडिफिकेशन को ट्रैक करता है  | जब इस track() function को execute किया जाता है तब ये प्रोग्राम किसी प्रोग्राम मे last compile प्रोसेस मे हुई changes को ट्रैक करता है और steps को hold भी करता है जो कसी प्रोग्राम को execute करने मे किया जाता है  |
borland c++ , Microsoft visual c++ और metrowerk code warrier भी इस तरह की facility देता है | जिसमे किस लम्बे प्रोग्राम को handle करने मे आसानी होती है |इस तरह के प्रोग्राम को design करने के लिए निन्म method को use किया जाता है :-
कसी प्रोघ्रम को break करने के लिए दो supporting function को दो अलग अलग file मे रखा जाता है |इस प्रोग्राम मे rectangular coordinator को polar coordinate मे convert किया जाता है |इस function main() मे दो प्रोग्राम को dotted lines से seperate नहीं किया जाता है | जब किसी structure को declare दोनों file मे सही तरह से declare किया जाता है |  अगर कसी एक struture मे चगेस किया जाता है तब स्दोनो declaration मे change किया जाता है | ये प्रॉब्लम को generate किया जाता है |
इस प्रॉब्लम को solve करने के लिए #include को use किया जाता है |  struture को file header मे लिखा जाता है | जिससे दोनों  files मे अलग अलग struture मे  मॉडिफिकेशन नहीं करना पड़ता है |
इस तरह प्रोग्राम को तीन मुख्य भागो मे convert किया जाता है :
1.header file : इस file मे , structure declaration और function prototype को declare किया जाता है |
2.source file : इस file मे , sturture related function को execute किया जाता है |
3.source file : इस file मे , structure function को call किया जाता है |

source code :\
In file struct

#ifndef COORDIN_H
#define COORDIN_H

struct polar {
double dis;
double angle;
};
struct rect
{
double a;
double b;
};
polar convert(rect);
void show(polar);

In file 1 :
#include<iostream.h>
#include<conio.h>
#include struct
using namespace std;
int main()
{
rect r;
polar p;
cout<<“Enter value of ‘x’ or ‘y’ :”;
while(cin>>r.a >> r.b)
{
p = convert(r);
show_polar(p);
cout<<“Next two number // For Quit , Enter ‘q’ “;
}
cout<<“Have a nice day !”;
getch();
}

In file 2
#include<iostream.h>
#include<conio.h>
#include struct
using namespace std;
polar convert(rect rec)
{
polar out;
out.dis = sqrt(rec.a*rec*a +rec.b*rec.b);
out.angle = atan(rec.b ,rec.a);
return out;
}
void show(polar output )
{
const degree = 57.295;
cout<<“Distance :”<<output.dis;
cout<<“Angle ( in rad ) : “<<output.angle;
cout<<“Angle ( in degree) :”<<output.angle * degree ;
}

इस उदाहरन से प्रोग्राम के design का एक नया रूप ही discuss किया है इस design पर based कुछ उदहारण निन्म है :

उदहारण मे :
इस उदाहरन मे , दो  file को use किया जाता है जिसमे class math को header file मे declare किया जाता है | और  main() function को  file1 मे declare किये जाता है |
class math को header file मे इसलिए  declare किये जाता है क्योकि इसे किसी भी प्रोग्राम मे use किया जा सकता है | इस header file मे  declare math class मे मुख्य चार functions को use किया जाता है |
add( ) : इस function से addition()को calculate करने  के  किया जाता है |
sub() : इस function मे subtrction को calculate किया जाता है |
mul() : इस function का use multiplication को calculate करने के लिए किया जाता है |
div() : इस function का use division को calculate करने के लिए किया जाता है |

file 2 मे main() को declare किया जाता है | जिसमे class math के function को use किया जाता है |

Header file मे

class math ()
{
private :
int output;
public:
// Function definition
void add(int a, int b)
{
output = a + b;
cout<<“Output : “<<output;
}
public:
// Function definition
void div(int a, int b)
{
output = a / b;
cout<<“Output : “<<output;
}
public:
// Function definition
void sub(int a, int b)
{
output = a – b;
cout<<“Output : “<<output;
}
public:
// Function definition
void mul(int a, int b)
{
output = a * b;
cout<<“Output : “<<output;
}
};

file 1 मे
#include <iostream>
#include<conio.h>
#include header
using namespace std;
void  main()
{
math  c;
int n1 , n2 ;
char choice ;
cout<<“Enter ‘+’ for addition”<<endl
<<“Enter ‘-‘ for subtraction”<<endl
<<“Enter ‘*’ for multiplication”<<endl
<<“Enter ‘/’ for division”<<endl;
cout<<“Enter choice : “;
cin >> choice;
cout<<“Enter n1 : “;
cin >> n1;
cout<<“Enters n2 : “;
cin >> n2;
switch(choice)
{
case ‘+’ :
c.add(n1,n2);
break;
case ‘-‘ :
c.sub(n1,n2);
break;
case ‘*’ :
c.mul(n1,n2);
break;
case ‘/’ :
c.div(n1,n2);
break;
default :
cout<<“invalid choice “;
break;
}
getch();
}