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

  • Home
  • SEARCH
  • 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 7018987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:07:25+00:00 2026-05-27T23:07:25+00:00

I have a base interface class: class A { public: ITask(){} virtual bool Start()=0;

  • 0

I have a base interface class:

class A
{
public:
    ITask(){}
    virtual bool Start()=0;
    virtual void Update()=0;
    virtual void Stop()=0;
};

I now have 2 other classes, that inherit from this

#include "A.h"
#include "C.h"
class B: public A
{
public:
    bool Start(){} 
    void Update()
    {
        c.Start();
    } 
    void Stop(){}

    static bool m_run;

    static void SetRun(bool run)
    {
        m_run = run;
    }
private:
    C c;
};

lastly I have a 3rd class:

#include "A.h"
#include "B.h"
class C : public A
{
public:
    bool Start()
    {
        B::SetRun(false); // cant do this
        B::m_run = false; // or this
    }
    void Update()
    {

    }
    void Stop()
    {

    }
}

I have shaved down some of the code, for simplicity.

I dont understand why I cant access the static var in B. Do I need to make it a pointer or a ref?

I get 2 errors:

error C2653: 'B' : is not a class or namespace name
error C3861: 'm_run': identifier not found
  • 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-27T23:07:25+00:00Added an answer on May 27, 2026 at 11:07 pm

    Although you don’t show it, I’m assuming that B.h includes C.h; otherwise the line C c; won’t compile. This causes a circular dependency in the header files: B.h must be included before C.h, which must be included before B.h, which is impossible.

    The easiest solution is to move the body of C::Start out of the definition of C, so that C.h does not need to include B.h. The function definition can go into a source file, or a separate header if you want to keep it inline.

    Alternatively, you could modify B to contain a std::unique_ptr<C> rather than an instance of C, and implement a constructor (in a source file, or a separate header) that initialises it with new C. Then B.h only needs to forward declare class C; rather than including C.h.

    A better solution, if possible, would be to rethink the relationships between the classes so that there isn’t a circular dependency.

    (UPDATE: while I was writing this answer, the question changed to show that B.h does indeed include C.h as I guessed.)

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

Sidebar

Related Questions

I have the following base interface public interface IBaseAction { bool CanAct(...) } and
I have an interface with several events I have base class implementing the interface
I have an abstract base class which acts as an interface. I have two
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC
In the project I'm working on now, we have base Entity class that looks
I have a base class with an optional virtual function class Base { virtual
I'm constructing a fluent interface where I have a base class that contains the
I have two classes public class PrepaidPackage { private String name; private String serviceClassID;
I have this base class having the following interface: abstract class Base { abstract
I have a base class: class RedBlackTreeNode { // Interface is the same as

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.