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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:18:17+00:00 2026-06-18T21:18:17+00:00

Below I have reproduced a simplified version of a part of my code that

  • 0

Below I have reproduced a simplified version of a part of my code that gives error when compiling.

testing.cpp

#include <iostream>
#include "../Beta.h"
#include "../Alpha.h"

using namespace std;

int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

Alpha.h

#include <vector>

class Alpha
{
    public:

        typedef struct _info{
            int  k;
        } info;

        friend class Beta;
};

Beta.h

   #include <vector>
    
        class Alpha;
        
        class Beta
        {
            public:
            std::vector <Alpha::info*> vecInfo;
        };

When I run g++ testing.cpp I get below error message

In file included from testing.cpp:10:0: ../Beta.h:8:15: error:

incomplete type ‘Alpha’ used in nested name specifier ../Beta.h:8:15:

error: incomplete type ‘Alpha’ used in nested name specifier

../Beta.h:8:27: error: template argument 1 is invalid ../Beta.h:8:27:

error: template argument 2 is invalid

I can see from the forum threads that the first error is because of some kind of cyclic dependency (Error: incomplete type used in nested name specifier). I am unable to see similarity between my code and their code. What am I doing wrong.

  • 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-18T21:18:18+00:00Added an answer on June 18, 2026 at 9:18 pm

    You need to include Alpha.h in Beta.h, because the full class definition is needed to have access to Alpha::info. This will not create a cyclic dependency because Alpha.h does not include Beta.h.

    // don't forget the include guards!
    #ifndef BETA_H_
    #define BETA_H_
    
    #include <vector>
    #include "../Alpha.h"
    
    class Beta
    {
        public:
        std::vector <Alpha::info*> vecInfo;
    };
    
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simplified and reproduced my problem in the code below. The error that
below i have a code that runs in most of my simple programs ..
I have the code below that is supposed to draw lines from the top
Below I have a function that animates a div ( container ) either to
Below I have a line of code where it states which Session a user
Below I have written a sample program that I have written to learn about
I have below snippet of code in which TestClass is extending jPanel which is
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
(Note that I've searched online for the warnings I'm describing below, and have come
In the example enumeration code given in this question , reproduced below, why does

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.