fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class personalPassword{
  5. private:
  6. char password [15];
  7. char passptr;
  8. public:
  9. personalpassword()
  10. {
  11. strcpy(password, 'NULL')
  12. passptr=password;
  13. cout<<"The default constructor called";
  14. cout<<"The Default value of password is : "<<password;
  15. count<<endl;
  16. count<<"The Default value of password pointer is"<<passptr;
  17. }
  18. void setPass(){
  19. cout<<"Please Enter the Password:";
  20. cin>>password;
  21. }
  22. char *getPass() const{
  23. return passptr;
  24. }
  25. void passEncrypt(){
  26. char key = 'k';
  27. for (int i=0; i<strlen(password); i++)
  28. password[i]= password[i] ^ key;
  29. cout<<"The encrypted password using the passEncrypt() function is:"<<password<<endl;
  30. }
  31. void passDcrypt(){
  32. char key = 'k';
  33. for(int i=0; i<strlen(password); i++)
  34. password[i] = password[i]^ key;
  35. count<<"The decrypted password using the passDecrypt()function is :"<<password<<endl;
  36. }
  37. };
  38. int main()
  39. {
  40. personalPassword pass;
  41. pass.setPass();
  42. count<<"The Password via getter function is:"<<pass.getPass()<<endl;
  43. pass.passEncrypt();
  44. pass.passDcrypt();
  45. return 0;
  46. }
  47.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:11:18: warning: multi-character character constant [-Wmultichar]
 strcpy(password, 'NULL')
                  ^~~~~~
prog.cpp:9:18: error: ISO C++ forbids declaration of ‘personalpassword’ with no type [-fpermissive]
 personalpassword()
                  ^
prog.cpp: In member function ‘int personalPassword::personalpassword()’:
prog.cpp:11:24: error: ‘strcpy’ was not declared in this scope
 strcpy(password, 'NULL')
                        ^
prog.cpp:15:1: error: ‘count’ was not declared in this scope
 count<<endl;
 ^~~~~
prog.cpp: In member function ‘char* personalPassword::getPass() const’:
prog.cpp:23:8: error: invalid conversion from ‘char’ to ‘char*’ [-fpermissive]
 return passptr;
        ^~~~~~~
prog.cpp: In member function ‘void personalPassword::passEncrypt()’:
prog.cpp:27:32: error: ‘strlen’ was not declared in this scope
 for (int i=0; i<strlen(password); i++)
                                ^
prog.cpp: In member function ‘void personalPassword::passDcrypt()’:
prog.cpp:33:31: error: ‘strlen’ was not declared in this scope
 for(int i=0; i<strlen(password); i++)
                               ^
prog.cpp:35:1: error: ‘count’ was not declared in this scope
 count<<"The decrypted password using the passDecrypt()function is :"<<password<<endl;
 ^~~~~
prog.cpp: In function ‘int main()’:
prog.cpp:42:1: error: ‘count’ was not declared in this scope
 count<<"The Password via getter function is:"<<pass.getPass()<<endl;
 ^~~~~
stdout
Standard output is empty