Question
C++ here is the code: #include #include #include using namespace std; class Encryption { protected: ifstream inFile; ofstream outFile; public: Encryption(char *inFileName, char *outFileName); ~Encryption();
C++
here is the code:
#include
class Encryption { protected: ifstream inFile; ofstream outFile; public: Encryption(char *inFileName, char *outFileName); ~Encryption(); virtual char transform(char ch) const = 0; void encrypt();
};
Encryption::Encryption(char *inFileName, char *outFileName) { inFile.open(inFileName); outFile.open(outFileName); if (!inFile) { cout
void Encryption::encrypt() { char ch; char transCh; inFile.get(ch); while (!inFile.fail()) { transCh = transform(ch); outFile.put(transCh); inFile.get(ch); } }
class SimpleEncryption : public Encryption { public: char transform(char ch) const { return ch+1; } SimpleEncryption(char *inFileName, char *outFileName) : Encryption(inFileName, outFileName) { } };
int main() { char inFileName[80], outFileName[80]; cout > inFileName; cout > outFileName; SimpleEncryption obfuscate(inFileName, outFileName); obfuscate.encrypt(); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started