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";
	}
}
the syntax for overloading an operator is:
 
[type] operator [op]([paramters]){};


http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B

look for bitwise operators.
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.