overloading ^ operator
Hi,
I want the C++ source code for overloading ^ operator using operator function in operator overloading.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
int main(void)
{
bool ex1=true;
bool ex2=true;
if((ex1&&ex2)^true)
{
std::cout<<"XOR: True";
}
else
{
std::cout<<"XOR: False";
}
}
|
Also known as the high five operator:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
#include <string>
class GeneriClass
{
public:
GeneriClass(const std::string & s) : _name(s) {}
void operator^(const GeneriClass& other) const
{
std::cout << _name << " high fives " << other._name << "!\n" ;
}
private:
std::string _name ;
};
int main()
{
GeneriClass A("Tyrone") ;
GeneriClass B("Evander") ;
A^B ;
}
|
Topic archived. No new replies allowed.