#include<iostream>
#include<string>
using namespace std;
class binary{
private: string s;
void binary :: checkmate(void){
for (int i = 0; i < [Link](); i++)
{
if ([Link](i)!='1' && [Link](i)!='0')
{
cout<<"This isn't in a binary form."<<endl;
exit(0);
}
}
}
void checkmate(void);
public:
void read(void);
void checkmate(void);
void exchange(void);
void display(void);
};
void binary :: read(void){
cout<<"Enter binary number - ";
cin>>s;
}
void binary :: exchange(void){
checkmate(); //Here this function can be operated as it can be used by only the
methods of the class and not any outside method like int main().
for (int i = 0; i < [Link](); i++)
{
if ([Link](i)=='0')
{
[Link](i)='1';
}
else{
[Link](i)='0';
}
}
}
void binary :: display(void)
{
cout<<"Displaying your binary number = ";
for (int i = 0; i < [Link](); i++)
{
cout<<[Link](i);
}
cout<<endl;
}
int main(){
binary b;
[Link]();
// [Link]();Here if we dont want user to use this we can make this private
[Link]();
[Link]();
[Link]();
//Nested: Nesting helps us to use our functions in another function without using
the above syntaxes
//Here the code will give an error and the reason behind this is we have to write
the checkmate method code inside the private class and not outside.
}