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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:16:06+00:00 2026-05-31T09:16:06+00:00

I’m trying to implement a class that has pointers for class members and methods

  • 0

I’m trying to implement a class that has pointers for class members and methods that return pointers but on compile I get “syntax error : missing ‘;’ before ‘*'” and “missing type specifier – int assumed. Note: C++ does not support default-int” errors

Here’s the code:
Main.cpp:

#include "AClass.h"
#include "BClass.h"

int main ( int argc, const char* argv[] )
{
    AClass a;
    BClass b;
    return 0;
}

AClass.h:

#ifndef ACLASS_H
#define ACLASS_H

#include "BClass.h"

class AClass
{
public:
    BClass* getB ();
    void setB (BClass* inst);
private:
    BClass* b;
};

#endif

BClass.h:

#ifndef BCLASS_H
#define BCLASS_H

#include "AClass.h"

class BClass
{
public:
    AClass* getA ();
    void setA (AClass* inst);
private:
    AClass* a;
};

#endif

I haven’t even fleshed out the classes with cpp files and I get a string of errors:
It doesn’t matter if I create the C++ files and define everything, these errors remain.

1>------ Build started: Project: memberUDFpointers, Configuration: Debug Win32 ------
1>  Main.cpp
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(9): error C2143: syntax error : missing ';' before '*'
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(9): warning C4183: 'getA': missing return type; assumed to be a member function returning 'int'
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(10): error C2061: syntax error : identifier 'AClass'
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(12): error C2143: syntax error : missing ';' before '*'
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents\cpp projects\memberudfpointers\memberudfpointers\bclass.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I’ve looked at many different posts all over but am still scratching my head on this one.
Can someone give me a clue?

  • 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-31T09:16:07+00:00Added an answer on May 31, 2026 at 9:16 am

    Your definition of AClass depends on the definition of BClass, and the definition of BClass depends on the definition of AClass. You can’t define one before the other has already been defined.

    Fortunately, the actual classes only use pointers to the other, so you can just declare one class:

    class A;
    
    class Bclass { 
        // ...
    };
    

    and go from there.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I'm trying to create an if statement in PHP that prevents a single post
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

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.