I will specify the reason for my error.
Please rectify my error:
CODE
private:
CStringArray m_strMnemonicArray;
public:
CStringArray getMnemonicSet();
CStringArray CParserDlg::getMnemonicSet()
{
return m_strMnemonicArray;
}
I have automated several tasks into a function shown below:
return the CStringArray by reference, not value.
Not only would this get rid of the compiler error, it is also a rule of thumb in C++ to pass objects such as CStringArray by either (const) reference, or if not, by pointer.
The reason is that passing by value incurs a temporary copy of the object. If not aware of it, passing objects by value will yield undesirable results, both in execution time and in wrong results (i.e. expecting the passed in object to have changed within the function).
The underlying reason for the error is that CObject is not copyable, but you are passing a CStringArray (which is derived from CObject) by value. Passing by value means that the compiler will attempt to make a temporary copy of the object. Since CObject has no available copy constructor, the compiler gives you the error.
But to add, I would much prefer this than CStringArray:
Then you wouldn’t have gotten the compiler error, since vector is copyable (but you would get the problem of the execution time and possible erroneous results I mentioned earlier).