整数的补数是当你把所有0转为1和所有1转为0在二进制表示时得到的整数.例如,整数5是101"在二进制中,它的补数是010",这是整数2.给出整数num,返回其补数.给我C++解决方案.
Here is the C++ solution to find the complement of an integer:

```
class Solution {
public:
    int findComplement(int num) {
        int bit = 1;
        while (bit < num) {
            bit = (bit << 1) | 1;
        }
        return num ^ bit;
    }
};
```

The solution works by first finding the binary representation of the given integer. It then creates a binary number with the same number of bits by left shifting a 1 bit, and then OR'ing it with itself. This creates a binary number in which all the bits are 1. 

We then XOR this number with the given integer to find its complement.