I'm trying to compare two arrays and check if they equal each other at any point in their arrays. Each array is from a different class. I get the error: invalid operands to binary expression('PlayerColor' and 'Colors'). What can I do to fix this problem? Also near the top of the code is bool correct[answer->getSize()]; is this correct?
This really should be a method of the Keys class (which you didn;t show).
You have some memory issues in your program:
Line 30: Your default constructor does not allocate answerArray. However you destructor at line 37 deallocates it unconditionally. This will cause a run time error attempting to release memory that is not allocated.
Also near the top of the code is bool correct[answer->getSize()]; is this correct?
No. C++ requires that the size of an array is known at compile time. You can however allocate a variable size array via new
Ok so in my main class I make the objects Colors answer and PlayerColors playerGuess. How do I make them into Key objects, but still am able to use Colors and PlayerColors member functions?
That's because line 51 is a pure virtual function. You have no implementation for it in the Keys class.
Not sure what getCode is supposed to do. In Colors, it outputs answerArray to cout.
I'm guessing that you really want the array as part of Keys. That way both Colors and PlayerColors inherit the array. You can then move getCode to the base class (Keys) and eliminate the pure virtual function.
I have to have a pure virtual function and Colors and PlayerColors are two completely different array's. one is randomly generated and the other a user inputs. I think my entire code just crumbled. :(
yes they are both arrays of colors (characters), but they are created in their respective classes not in the key class because I want to be able to use their member functions. Actually Colors array is made by one of it's member function.
So for now I've ditch the virtual function until later, but am currently having a problem with comparing the two arrays since they are from different classes and making them both Key objects makes life really difficult. Don't they inherit from Key class anyway? You'd think that would make you able to compare the two derived class with each other.