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

The Archive Base Latest Questions

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

I have put several instances of class b in class a but this causes

  • 0

I have put several instances of class b in class a but this causes an error as class a does not know what class b is.

Now I know I can solve this problem by writing my file b a c but this messes up the reachability as well as annoys me. I know I can prototype my functions so I do not have this problem but have been able to find no material on how to prototype a class.

does anyone have an example of class prototyping in c++.

as there seems to be some confusion let me show you what i want

class A
{
public:

B foo[5];

};

class B
{
public:
int foo;
char bar;
}

but this does not work as A cannot see B so i need to put something before them both, if it was a function i would put A(); then implement it later. how can i do this with a class.

  • 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:19:15+00:00Added an answer on May 22, 2026 at 9:19 pm

    You can declare all your classes and then define them in any order, like so:

    // Declare my classes
    class A;
    class B;
    class C;
    
    // Define my classes (any order will do)
    class A { ... };
    class B { ... };
    class C { ... };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class Slide , of which I want to place several instances
I have an abstract class A and several implementations of it. I expect this
I have put several buttons and panels in my update panel. I also have
I have several tables that I want to put side by side, however when
I have several constants that I use, and my plan was to put them
I'm trying to put together a form_tag that edits several Shift objects. I have
First let me explain. I have several addresses on the page that I put
i have put my site in dropbox so you can see it http://dl.dropbox.com/u/13722201/Dorset%20Designs/home.html when
I have put together an image scroller using jquery, like this function rotateImages(whichHolder, start)
The questions I have are NOT homework questions, but I am considering using these

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.