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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:57:54+00:00 2026-06-11T17:57:54+00:00

class MyClass : public CObject { public: MyClass(); private: CStringArray m_myArray; }; causes error

  • 0
class MyClass : public CObject
{
public:
   MyClass();

private:
   CStringArray m_myArray;
};

causes error c2248

What’s wrong with this ?
I think it’s related to the fact that CStringArray and MyClass both derive from CObject.

Legacy class derived from CObject currently uses CustomArray it just seems wrong to me so I would like to replace it by CStringArray.

  • 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-11T17:57:55+00:00Added an answer on June 11, 2026 at 5:57 pm

    Microsoft compiler error C2248 means “Members of a derived class cannot access private members of a base class.”

    I can only assume you’re trying to directly reference MyClass::m_myArray from somewhere in your code, without using a public accessor function.

    Update
    The real answer is that the problem is caused by the copy-constructor for MyClass, attempting to copy m_myArray, but it can’t, because CObject derived classes aren’t copyable by default. The solution would be to write a copy constructor yourself, and rather than attempt to copy the array, copy the contents one at a time, from the source array to the destination array. Either that or use std::vector (which you should be doing anyway, as MFC containers are horrible).

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

Sidebar

Related Questions

I have a class like this: class MyClass{ public: MyClass(int Mode); private: std::map <
This is first way: Public Class MyClass Private _Property As String Property Property ()
class MyClass { public: void setVar(const char *str); private: std::string mStr; int maxLength; //we
I have a class MyClass: public class MyClass { private MyComplexType member1; } I
Say I have this class Myclass that contains this method: public class MyClass {
I have a class looking like this: class MyClass { public int Id; public
This works: class MyClass { int a; public MyClass() { int b = a;
public class MyClass { public string myString; public MyClass(string s) { this.myString = s;
I have this class: public class MyClass { public MyClass(){} public void actionA(){ synchronized(MyClass.class){
Class: class myclass { public: myclass(void); const char* server; private: char pidchar[6]; int pidnum;

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.