Question: General Instructions: In this assignment you will be implementing a SubstrExtractor in an object-oriented manner. Specifically, it will find the longest substring with distinct characters.
General Instructions: In this assignment you will be implementing a SubstrExtractor in an object-oriented manner. Specifically, it will find the longest substring with distinct characters. This program would involve some basic manipulation of strings and writing to files. The driver program is given to you and you are NOT allowed to change it. Hence, the obvious overloaded operators will be input >> and output <<.
Note: Any spaces in the input string should be ignored.
Specific Instructions:
This assignment should be written as a modular C++ program. You will develop a class (module) called SubstrExtractor, with header (.h) and implementation (.cpp) files. The main program should be in its own module, and it is given to you.
In this program, an input file with strings is provided to you. You are encouraged to add more lines of input. You need to find the longest substring with distinct characters as described below and print the output to a file. If an input string has multiple solutions, all of them should be listed.
Programming concepts that are expected in the solution:
1. Object oriented modular solution
2. File IO operation
3. Use of operator overloading
4. Use of friend function
Substring Extractor:
Given a string S that can contain any type of characters. If spaces are included, these should be taken out. Then you need to find the longest substring with distinct characters. If there are multiple substrings with same length, list all of them.
Example 1:
Input: S = "carrot"
Output: Longest substring: car, rot
Explanation: If a substring does not contain any repeated characters, whether adjacent or not, then the substring is distinct.
Driver Code:
#include
#include
using namespace std;
#include SubstrExtractor.h
int main() {
SubstrExtractor my_extr;
std::ifstream file_in("input.txt");
std::ofstream file_out("output.txt");
if (file_in.is_open() && file_out.is_open())
{
while (file_in)
{
file_in >> my_extr;
my_extr.find_ldsubstr();
file_out << my_extr;
}
}
return 0;
}
Input File:
{:>?/..}
A Long Weekend
Weekend
Corresponding Output File:
Longest Substrings:
{:>?/.
Longest Substrings:
ALongWe
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
