#include<iostream> #include<stdlib.h> #include<string.h> using namespace std; class A{ int a; public: void set_a(int a){ this->a=a; } int get_a(){ return a; } }; A operator !(A obj){ if(obj.get_a()%2==0){ cout<<"\n\nIt is a even number\n\n"; } else{cout<<"\n\nIt is a odd number \n\n";} } int main(){ A obj; int num; system("clear"); cout<<"Enter a number :"; cin>>num; obj.set_a(num); !obj; }
Enter a number 4
It is a even number
If you like code with vibhu and would like to contribute, you can also write an article using This link :
https://docs.google.com/forms/d/e/1FAIpQLScAmvlPvNUz35R-G0nc_zpRVP3o8xlhtFgC3aKPyLetX_RyXg/viewform?pli=1
OR mail your article to codewithvibhu@gmail.com. See your article appearing on the code with vibhu main page and help other students.
0 Comments