1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string.h>
using namespace std;
class var
{
int value;
char sir[255];
public:
var(int value);
var(char sir[]);
var(int value, char sir[]);
var(const var&Obj);
~var(){ cout<<" DESTRUCTOR value = "<<endl; }
void setVALUEm();
inline const int getVALUE()const{ return this->value; }
void setCHARm();
inline const char* getCHAR()const{ return this->sir; }
friend void ABC(var& , var& , var&, var&);
friend int ABC1(var& , var& , var& );
friend void POW(var&);
friend void parity(var&);
friend void calc(var&);
};
var::var(int value=NULL){ this->value=value; this->sir[0]=0; }
var::var(char sir[]) { this->value=NULL; (this->sir,sir); }
var::var(int value, char sir[]){ this->value=value; strcpy(this->sir,sir);}
var::var(const var&Obj){ this->value = Obj.value; strcpy(this->sir,Obj.sir); }
void var::setVALUEm(){ cout<<" Enter value="; cin>>this->value; }
void var::setCHARm(){ cout<<" Enter value char="; cin>>this->sir; }
void ABC(var&a, var&b, var&c, var&R ) { R.value=a.value+b.value-c.value; cout<<" friend a+b-c="<<R.value<<endl; }
int ABC1(var&a, var&b, var&c){ return a.value+b.value-c.value; }
void POW(var&X)
{
int p;
cout<<"enter p= "<<endl;
cin>>p;
X.value= pow(X.value, p);
}
void parity(var&X)
{
if(X.value%2==0) cout<<"EVEN"<<endl;
else cout<<"ODD"<<endl;
}
void calc(var&X)
{
strlen(X.sir);
}
int main()
{
var A=10,B=11,C=12,R, r=ABC1(A,B,C), Y;
cout<<" a+b-c="<<A.getVALUE()+B.getVALUE()-C.getVALUE()<<endl;
ABC(A,B,C,R);
cout<<" R="<<R.getVALUE()<<endl;
cout<<" r="<<r.getVALUE()<<endl;
cout<<endl;
POW(A);
POW(B);
POW(C);
cout<<"A="<<A.getVALUE()<<endl;
cout<<"B="<<B.getVALUE()<<endl;
cout<<"C="<<C.getVALUE()<<endl;
cout<<endl;
parity(A);
parity(B);
parity(C);
cout<<"A="<<A.getVALUE()<<endl;
cout<<"B="<<B.getVALUE()<<endl;
cout<<"C="<<C.getVALUE()<<endl;
cout<<endl;
Y.setCHARm();
cout<<" CHAR array= "<<Y.getCHAR()<<endl;
calc(Y);
cout<<" CHAR array 1= "<<Y.getCHAR()<<endl;
return 0;
}
|