Question
Cpp 11 You will be implementing a weak version of the vector class, which will be a dynamic array of string variables. This array is
Cpp 11 You will be implementing a weak version of the vector class, which will be a dynamic array of string variables. This array is expected to expand when necessary and have the ability to be copied, either for initialization or for setting two existing objects equal to each other. Class Requirements: Use the provided file PFAString.hpp as a guide. Do NOT change the name of the header file. The name of your implementation file shall be PFAString.cpp NOTE: The header file is an outline, and you are required to flesh it out (const where needed, etc.) The provided header file is a base to work on. Nothing should be removed, function names should not be changed, but you are free to add private helper functions and additional functions and member variables as you see fit The copy constructor should construct the new object to have a capacity equal to the size of the object being copied. The same holds true for the copy operator overload of = The overloaded [ ] should be written so that it can function as an l-value For the relational overloads, the comparison should be lexicographical NOTE: You are NOT allowed to use the lexicographical compare algorithm http://www.cplusplus.com/reference/vector/vector/operators/ http://www.cplusplus.com/reference/algorithm/lexicographical_compare/ Reading these resources will save you a lot of unnecessary work When the array is expanded, it MUST expand to twice its previous capacity. I.E., an array of capacity 20 will expand to capacity 40 when an attempt to add a 21st element occurs For further clarification, read about the equivalent function in the class on either cplusplus. com or cppreference.com main.cpp Requirements: Your assignment will be graded using a main.cpp that I provide I will not make it available to you until the last week of the assignment period It is important for you to learn to test your classes yourselves Thouroughly test your class! This means testing each operator, and trying to break it 1 Failure to compile your class against the main.cpp used for grading usually indicates a failure to properly test, especially edge cases Expected behaviors: The default capacity and size are zero An object capacity cannot be less than zero. Set it to zero Any attempt at out-of-bounds array access should result in an error message, and immediate ending of the program. Allowing out-of-bounds access and manipulation is too dangerous in the shared Linux Lab environment If the copy constructor or overloaded copy = is used, the l-value object should have a capacity equal to the size of the r-value object makefile Requirements Your makefile must still include the requisite comment block Your makefile must compile each class separately Your makefile must include a clean rule Your makefile will use the following variables CXX CXXFLAGS SRCS SRCSDIR OBJS EXE $@ $ $< Your makefile will include the special built-in target .PHONY Your makefile will make use of the following function/wildcard addprefix % Reminders: Include a makefile! Be sure to include a comment block at the top of every file with the required information Refer to the General Homework Requirements handout on Blackboard Provide meaningful comments If you think a comment is redundant, it probably is 2
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