Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

File Filter A file filter reads an input file, transforms it in some way, and writes the results to an output file. Write an abstract

File Filter A file filter reads an input file, transforms it in some way, and writes the results to an output file. Write an abstract file filter class that defines a pure virtual function for transforming a character. Create one subclass of your file filter class that performs encryption, another that transforms a file to all uppercase, and another that creates an unchanged copy of the original file. The class should have a member function void doFilter(ifstream &in, ofstream &out) that is called to perform the actual filtering. The member function for transforming a single character should have the prototype char transform(char ch) The encryption class should have a constructor that takes an integer as an argument and uses it as the encrytion key. Please show me the header and .cpp files

FileFilter:

FilterFile.h:

#ifndef FILEFILTER_H #define FILEFILTER_H #include #include #include using namespace std;

class FileFilter { public: virtual char transform(char ch)= 0; void doFilter(ifstream&in, ofstream&out); char ch; char transCh; in.get(ch); while(!in.fail()) { trans Ch = transform(ch); out.put(trans Ch); in.get(ch); } };

Has a uninterminated #indef

in does not name a type

unexpected unequalified id before while

Encryption.h:

class Encryption : public FileFilter { private: int key; public: char transform(char ch) { return ch + key; } Encryption (int enckey) { key = enckey; } }; class Unchanged : public FileFilter { public: char transform (char ch) { return ch; } }; class DoubleSpace : public FileFilter { public: char transform(char ch) { } };

main. cpp:

int main() { ifstream inFile; ofstream outFile; char inFileName[100], outFileName[100]; int offset; cout << "the files are called: "; cin>> inFileName; inFile.open(inFileName); cout << "enter a file to recieve a double spaced copy: "; cin >> outFileName; outFile.open(outFileName); while (!outFile) { cout << "File opening error, please re-enter name: "; cin >> outFileName; } DoubleSpace double Space; doubleSpace.doFilter(inFile, outFile); infile.close(); outfile.close(); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions