পোস্টগুলি

জানুয়ারী, ২০২০ থেকে পোস্টগুলি দেখানো হচ্ছে

Friend function must use

ছবি
code: #include<iostream> using namespace std; class complex{ private:     int a,b; public:     complex(){a=0,b=0;}     complex(int a,int b){         this->a=a;         this->b=b;     }     void show(){         cout<<a<<'+'<<b<<'i'<<endl;     }     friend void operator<<(ostream&,complex); }; void operator<<(ostream &bout,complex C){     cout<<"In overloaded operator"<<endl;     cout<<C.a<<'+'<<C.b<<'i'; } int main() {     complex com1(2,5),com2(3,7);     com1.show();     cout<<com1;     cout<<com2;     return 0; } If we want to print more than one value t...

pree or post operator overloading

ছবি
Code: #include<iostream> using namespace std; class complex{ protected:     int x,y; public:     complex(){x=0,y=0;}     complex(int x,int y){         this->x=x;         this->y=y;     }void show(){cout<<x<<'+'<<y<<'i'<<endl;}     complex operator++(){         ++x;         ++y;         return *this;     }     complex operator++(int ){         complex temp;         temp.x=x++;         temp.y=y++;         return temp;     } }; int main() {     complex ob1(2,4),ob2,ob3(2,4);     ob1.show(...

Big mod

ছবি
Code: #include<iostream> using namespace std; int main() {     int mod_num;     string str;     while(1){         cout<<"Enter the Big number: ";         cin>>str;         cout<<"Enter the mod number: ";         cin>>mod_num;         int temp=0;         for(int i=0;str[i]!='\0';i++){             temp*=10;             temp+=(str[i]-'0');             temp%=mod_num;         }cout<<"The mod value of "<<str<<" % "<<mod_num<<" = "<<temp<<endl;     }  ...

Operator Overloading (Example)

ছবি
Example code: #include<iostream> using namespace std; class student{     int a;     int b;     string name; public:     student(){         a=0;         b=0;         name="No name.";     }     student(int a,int b,string name){         this->a=a;         this->b=b;         this->name=name;     }     void print(){         cout<<"a = "<<a<<endl;         cout<<"b = "<<b<<endl;         cout<<"Name = "<<name<<endl;     }     student operator +(student ob); }; student ...