Edit: corrected a sentence.
- - -
error: invalid user-defined conversion from 'char [81]' to 'const ccAssignmentOprOverload&'
1 2 3
|
char temp[81];
isObject>>setw(81)>> temp;
str = temp;
|
|
'temp' is defined as a char array -->
char temp[81];
'str' is defined as a ccAssignmentOprOverload -->
const ccAssignmentOprOverload& str
When you write
str = temp;
the compiler tells you it doesn't know how to convert
an instance of the class 'ccAssignmentOprOverload' into a character array a character array into an instance of the class 'ccAssignmentOprOverload'.
It's hard to guess what you are trying to do, because it seems you want the characters you read from std::cin, and which you store into 'temp', to be copied into ccAssignmentOprOverload::list.
If so:
- on one hand, inside class ccAssignmentOprOverload there should be a property like
char* list;
- on the other hand, inside your constructor
ccAssignmentOprOverload(int size) you initialize it as
list = new int[maxSize];
Hence, it looks more like a "int* list;" than a "char* list;"...
To solve your issue, you could add another overloaded operator=, perhaps like so:
ccAssignmentOprOverload& operator= (const char* const input);
which takes care of the conversion from a char* to a ccAssignmentOprOverload instance.
Maybe we could help better if you posted also your header file and an example of the input you plan to provide at runtime.
Happy coding!