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 8335149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:34:42+00:00 2026-06-09T03:34:42+00:00

Im trying to return a CStringArray: In my .h I defined: Private: CStringArray array;

  • 0

Im trying to return a CStringArray:
In my “.h” I defined:

    Private:
    CStringArray array;

    public:
    CStringArray& GetArray();

In . cpp I have:

    CQueue::CQueue()
    {
    m_hApp = 0;
    m_default = NULL;
    }


    CQueue::~CQueue()
    {

     DeleteQueue();
    }

    CStringArray& CQueue::GetArray()
    {

     return array;   
    }

From another file I’m trying to call it by:

    CStringArray LastUsedDes = cqueue.GetArray();

I guess it is because of the above line that I get the error:

   error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject'
  • 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-06-09T03:34:45+00:00Added an answer on June 9, 2026 at 3:34 am

    The problem is on this line

    CStringArray LastUsedDes = cqueue.GetArray();
    

    Even though you’re returning a reference to the CStringArray in the GetArray() function a copy of the array is being made in the line above. CStringArray itself doesn’t define a copy constructor and it derives from CObject, which has a private copy constructor.

    Change the line to

    CStringArray& LastUsedDes = cqueue.GetArray();
    

    But be aware that LastUsedDes now refers to the same CStringArray contained in your class instance, and any changes made to one will be visible in the other.

    If you need a local copy of the returned array you can use the Append member function to copy the contents.

    CStringArray LastUsedDes;                // default construct the array
    LastUsedDes.Append( cqueue.GetArray() ); // this will copy the contents of the
                                             // returned array to the local array
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to return an array. Consider the following code. public Quiz[] getMark(){ }
I'm trying to return a left child as a pointer I have template <typename
I am trying to return twitter titles based on today's date only. I have
I am trying to return a String from the following method. public String openCon()
I am trying to return all MSFT Lync Users who have used voice conferencing
Trying to return a DB resultset as an array in my DAO: I want
I am trying to return a list of ungrouped values having a max defined
I'm trying to return a byte array containing the two's-complement representation of a Bignum
I have been trying to return an ARABIC string from a JNI call. The
I'm trying to return a 2d array from call(), I'm having some issues. My

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.