エラーが出るのですが、どこがうまく行ってないのかわかりません。
条件はclassを使って,ひとつはprivate member data stringをプリントするためで。
後はデコードとエンコードのためのpublicなのですが、条件ともかなり違うような気がします
C++をはじめてまだ日が浅いです、よろしくお願いします。
#include <iostream>
#include <string>
using namespace std;
class Caesar
{
public:
void Encode();
void Decode();
};
void Caesar::Encode()
{
string input;
int count=0, length;
cout<<"Please enter a string that you would like to encode"<<endl;
getline(cin, input);
length =(int) input.length();
int shiftnumber;
cout<<"please enter what integer cipher shift key you use?"<<endl;
cin>>shiftnumber;
for (count=0; count< length; count++)
{
if (isalpha (input [count]))
{
input[count]=tolower(input[count]);
for (int i=0; i<shiftnumber; i++)
{
if(input [count]=='z')
input [count]='a';
else
input[count]++;
}
}
}
cout<<"The answer is "<<input<<endl;
}
void Caesar::Decode()
{
string input;
int count=0, length;
cout<<"Please enter a string that you would like to encode"<<endl;
getline(cin, input);
length =(int) input.length();
int shiftnumber;
cout<<"please enter what integer cipher shift key you use?"<<endl;
cin>>shiftnumber;
for (count=0; count< length; count++)
{
if (isalpha (input [count]))
{
input[count]=tolower(input[count]);
for (int i=0; i<shiftnumber; i++)
{
if(input [count]=='a')
input [count]='z';
else
input[count]--;
}
}
}
cout<<"The answer is "<<input<<endl;
}
int mian()
{ Caesar PLayer;
cout<<"Welcome to the Caesar Encoder/Decoder!"<<endl;
string sentaku, mouika;
cout<<"Would you like to encode? please enter 'E'"<<endl;
cout<<"Would you like to decode? please enter 'D'"<<endl;
cout<<"or Quit please enter 'Q'"<<endl;
cin>>sentaku;
while(true)
{
if (sentaku=="E")
{PLayer.Encode();}
if (sentaku=="D")
{PLayer.Decode();}
if (sentaku=="Q")
{break;}
else
{continue;}
}
cout<<"Would you like to encode? please enter 'E'"<<endl;
cout<<"Would you like to decode? please enter 'D'"<<endl;
cout<<"or Quit please enter 'Q'"<<endl;
cin>>mouika;
return 0;
}