Expand|Select|Wrap|Line Numbers
- Stack& Stack::operator = (const Stack& rightOp)
- {
- if( this != &rightOp )
- {
- delete[] arraystack;
- arraysize = rightOp.arraysize;
- capacity = rightOp.capacity;
- arraystack = new int;
- strcpy( arraystack, rightOp.arraystack);
- }
- return *this;
- }
1. Check for self-assignment. If the address stored in the pointer this is the same as the address of the object rightOp, then skip to the final step.
2. Delete the string array for the object that called the method.
3. Set the string size for the object that called the method to the string size of rightOp.
4. Set the string capacity for the object that called the method to the string capacity of rightOp.
5. Use the string array pointer for the object that called the method to allocate an array of char. The size of the new string array should be the string capacity plus one.
6. Copy the contents of the string array of rightOp into the string array of the object that called the method.
7. Return *this.
The problem is when compile this code there is warning regarding the strcpy.
Anythig wrong with my code, please advise.Thank you