Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5981257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:55:08+00:00 2026-05-22T21:55:08+00:00

I will specify the reason for my error. Please rectify my error: CODE private:

  • 0

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;
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:55:08+00:00Added an answer on May 22, 2026 at 9:55 pm

    I have automated several tasks into a function shown below:

        CStringArray CParserDlg::getMnemonicSet();
    

    return the CStringArray by reference, not value.

       CStringArray& CParserDlg::getMnemonicSet();
    

    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:

      #include <vector>
      std::vector<CString> CStringVector;
    

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code in my Application. Comments in my code will specify My
For some reason, the following code will work: The following code does not work:
Does anyone know the correct way to explicitly specify which rules Gendarme will use?
With Spring MVC, you can specify that a particular URL will handled by a
Will the code below work if the clock on the server is ahead of
Is there a way to specify in an interface a known return type, but
Is there a way to specify in your layout which widgets will shift and
Will limiting a query to one result record, improve performance in a large(ish) MySQL
Will I have to pay again? I have about 9 months left before renewal
Will IE6 negotiate a 256 bit AES SSL connection if the server is capable?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.