bitwise XOR operator function

I compiled a simple program:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
#include<cstdlib>
#include<string>
#include<fstream>
using namespace std;

int main()
{
    string s="a";
    string k="5";
    k = k^s;
    system("PAUSE");
}


I got an error:no match for 'operator^'.I don't know what bitwise XOR does and i want to find it out by a simple program.Please help me out.Sorry for wasting your time on such simple questions.
Thank you for reading.
Bitwise operators only work with integers.
std::string doesn't support the bitwise XOR operator.
Change the type of s and k to char and you will be fine.
Note: You will need to change the values assigned to 'a' and '5' (single quotes).
Last edited on
thanks very much

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<cstdlib>
#include<string>
#include<fstream>
using namespace std;

int main()
{
    string s="a";
    string k="5";
    k[0] = k[0]^s[0];
    cout<<k;
    system("PAUSE");
}


This also worked.Thanks again.
Topic archived. No new replies allowed.