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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:53:57+00:00 2026-05-26T10:53:57+00:00

I’m trying to get around this error I get from Microsoft Visual Studio 10

  • 0

I’m trying to get around this error I get from Microsoft Visual Studio 10 Compiler. The error is:
Some class : error C2248: cannot access protected member declared in class ''. Here is code that reproduces this error. I can’t seem to figure out how to create an object that owns another object that has a protected default constructor. I have another constructor that takes an input parameter but can’t seem to call it no matter what logical reasoning I apply. Obviously, I’m missing something silly or really important, so I’m putting it on here to see if anyone can catch my error. Thanks to all!!!

#ifndef FOO_H
#define FOO_H

class Foo {
    public :
        int myFooInt;

        ~Foo();

        Foo(int fooInt);

    protected :   //Uncomment to generate C2248 Error
        Foo();
};

#endif

.

#include "foo.h"

Foo::Foo() {

}
Foo::Foo(int fooInt) : myFooInt(fooInt) {

}

Foo::~Foo() {
}

.

#ifndef GOO_H
#define GOO_H

#include "foo.h"

class Goo {
    public :

        ~Goo();

        Goo();

        Goo(Foo foo);

        Foo myFoo;

};

#endif 

.

#include "Goo.h"

Goo::Goo() {

}

Goo::Goo(Foo foo) : myFoo (foo) {
}

Goo::~Goo() {
}

.

#include "foo.h"
#include "goo.h"

void main() {
    Foo foo(5);
    Goo goo(foo);
}
  • 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-26T10:53:58+00:00Added an answer on May 26, 2026 at 10:53 am

    I have another constructor that takes an input parameter but can’t seem to call it no matter what logical reasoning I apply.

    Ah, now we get to the important part (and sorry that the other answers don’t seem to give you credit for understanding the protected keyword, but you do seem a bit confused the way you present your question). You do have that constructor, but you also have a default constructor. It doesn’t matter how many working constructors you write; the non-working one will still cause compile-time errors.

    Your default constructor for the container class has no initialization list, and therefore will attempt to use the default constructors for data members. Since you don’t have access to the member’s default constructor, compiling the container’s default constructor fails.

    Possible solution: explicitly initialize the member using another constructor, in the container’s default constructor’s initialization list. This means that you’ll have to make up the value somehow. (That isn’t always possible. When that happens, it’s the compiler’s way of telling you that having a default constructor doesn’t make sense for the container class. 🙂 )

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.