DNA base pair match counter So my code is done it outputs exactly what it needs to I'm just wondering if it is possible to make this code a lot more simple using objects. If so could someone tell me what I would need member-wise and I will try and implement it. When I tried it got way too complex and it ended up looking easier to just write functions and a whole ton of for loops with if statements. 

The purpose of the code is to analyze 2 inputs (base and template) and then see if the template matches any chunks on the base. Also called Gattaca, but A goes to T, C goes to G, and vice versa. 

Here is my code:

#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

bool AT(char a, char b)  {
    return ((a == 'A' &amp;&amp; b == 'T') || (b == 'A' &amp;&amp; a == 'T'));
}
bool CG(char a, char b)  {
    return ((a == 'C' &amp;&amp; b == 'G') || (b == 'C' &amp;&amp; a == 'G'));

}
bool match(char a, char b) {

    return (AT(a, b) || CG(a, b));
}

int main() {
int case_count = 0;
string base;
string temp;
int base_size;
int temp_size;
int count;
cin &gt;&gt; case_count;

for (int i = 0; i &lt; case_count; ++i) {
    cout &lt;&lt; "Case " &lt;&lt; i &lt;&lt; ":\n";
    bool check = false;
    cin &gt;&gt; base;
    cin &gt;&gt; temp;
    base_size = base.size();
    temp_size = temp.size();

    if (base_size &lt; temp_size) {
        cout &lt;&lt; "None";
        continue;
    }
    if (base_size == temp_size) {
        count = 0;
        for (int index = 0; index &lt; base_size; ++index) {
            if (!(match(base[index], temp[index]))) {
                cout &lt;&lt; "None\n";
                break;
            }
            else 
                count++;

        }
        if (count == temp_size) {
            cout &lt;&lt; "0\n";
        }
        continue;
    }
    for (int j = 0; j &lt; base_size - (temp_size+1); ++j) {
        count = 0;
        for (int k = j; k &lt; j + temp_size - 1; ++k) {
            if (!(match(base[k], temp[count]))) {
                break;
            }
            else
                count++;
        }
        if (count == temp_size - 1) {
            check = true;
            cout &lt;&lt; j &lt;&lt; " ";
        }

    }
    if (check == false) {
        cout &lt;&lt; "None \n";
    }
    else if (check == true) {
        cout &lt;&lt; "\n";

    }
}
return 0;
}


I'm new to C++ programming so the best I can think is using a class to make this look simple. I'm not looking for a full written program just an idea/pseudo code or just the member functions I could use to make this simple.
It is extremely difficult to understand what's going on in your code. Try to think of things the following perspective: the goal of programming is to tell other people what you want the computer to do. And what you want to do is match the template to the base as some location. So how can we make that clearer?

Rather than character-wise matching for the appropriate inversion, we can just invert the template and then we just have to match for equality. Suppose we have a function:

std::string invertDNA(std::string const&amp; );


which flips A/T and C/G. Once we have that inversion, we're just searching for the inverted match_template in base:

std::size_t index = base_template.find(invertDNA(match_template));
if (index == std::string::npos) {
    std::cout &lt;&lt; "None\n";
}
else {
    std::cout &lt;&lt; index &lt;&lt; '\n';
}


We've now reduced dozens of lines of loops and variables, which are error prone, into a one line standard algorithm which is very easy to both reason about and for other users to understand. I don't know anything about chemistry, but I get this!



For minor comments, avoid using namespace std; and keep your indentation consistent. You do not need variables for the string length, since you can always call .size(). Avoid comparing against true and false. That part can be if (!check) { ... } else { ... }