Finding Decimal Equivalent of a Binary Number

Hi there,
I am learning coding in C++. I would like to start, by making a full functional calculator. All of them are pretty done but I want some more options which are present in a scientific calculator, like binary calculation. I don't see any function for this. So I guess I have to make one.
I have been trying to add the binary to decimal conversion. I know that the basic process is:

But how do I take the digits 1 at a time. Should I take the binary number as a string or by integer? Please help.
