Complete Solutions
____ files contain data that is unformatted and not necessarily
stored as ascii text Correct Answers binary
____ is the default behavior when an object is assigned the value
of another object of the same class Correct Answers
memberwise assignment
_____ a list means traveling through the list Correct Answers
traversing
_____ are pointer-like objects used to access information stored
in a container Correct Answers iterators
_____ files contain information formatted as ASCII text Correct
Answers text
_____ is a special built-in pointer that is automatically passed as
a hidden argument to all nonstatic member fxns Correct
Answers this
_____ recursion is when function A calls function B, which in
turn calls function A Correct Answers indirect
______ recursion is when a fxn explicitly calls itself Correct
Answers direct
a ____ container organizes data in a sequential fashion similar to
an array Correct Answers sequence
,a ____ fxn is not a member of a class, but has access to the
private members of the class Correct Answers friend
a ____ is represented in memory as an array of characters with a
null terminator Correct Answers c-string
a _____ container uses keys to rapidly access elements Correct
Answers associative
a _____ is written in your program as a sequence of characters
surrounded by double quotes Correct Answers string literal
a ______ is a special constructor, called whenever a new object
is initialized with another object's data Correct Answers copy
constructor
a c-string is an array of characters terminated with the sentinel
value Correct Answers '\0'
a class that cannot be instantiated is called is a Correct Answers
abstract class
a class with at least one pure virtual member function is called a
_____ class Correct Answers abstract
a constructor that takes a single parameter of a type different
from the class type is a ____ constructor Correct Answers
convert
,A data structure that points to an object of the same type as itself
is known as a ______ data structure Correct Answers self
referential
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 do Filter(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 use it as the encryption key
Second part of the question:
Create a subclass of the abstract filter class of programming
challenge 5 (i.e example above) that double spaces a file: that is,
it inserts a blank Correct Answers #include "stdafx.h"
#include <fstream>
, #include <string>
#include <iostream>
using namespace std;
// FileFilter abstract class
class FileFilter
{
private: int key;
public:
FileFilter()
{
}
FileFilter(int key)
{
this->key=key;
}
char transform(char ch)const
{
if(ch>='a' && ch<='z')
return ((ch-'a')+key)%26+'a';
else if(ch>='A' && ch<='Z')
return ((ch-'A')+key)%26+'A';
}
virtual void doFilter(ifstream &in, ofstream &out)const=0;
//pure virtual function
};
//class Encryption
class Encryption : public FileFilter