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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:35:15+00:00 2026-06-03T01:35:15+00:00

I have two classes, Mesh and MeshList. I want MeshList to have a function

  • 0

I have two classes, Mesh and MeshList. I want MeshList to have a function that can change the private members of Mesh. But it won’t compile and I don’t know why. Here’s my code.

Mesh.h

#ifndef _MESH_H
#define _MESH_H

#include "MeshList.h"
#include <iostream>

class Mesh
{
private:
    unsigned int vboHandle_;
    friend void MeshList::UpdateVBOHandle();
public:
    inline void Out() {std::cout << vboHandle_;}
};
#endif

Mesh.cpp

#include "Mesh.h"

MeshList.h

#ifndef _MESH_LIST_H
#define _MESH_LIST_H

#include "Mesh.h"


class MeshList
{

public:
    Mesh *mesh; //Line 11 Error
    void UpdateVBOHandle();
};
#endif

MeshList.cpp

#include "MeshList.h"

void MeshList::UpdateVBOHandle()
{
    *mesh->vboHandle_ = 4;
}

I get these errors:

MeshList.h (Line 11)

  • error C2143: syntax error : missing ‘;’ before ‘*’
  • error C4430: missing type specifier – int assumed. Note: C++ does not
    support default-int
  • error C4430: missing type specifier – int assumed. Note: C++ does not
    support default-int

  • mesh.h(11) : error C2653: ‘MeshList’ : is not a class or namespace
    name

  • meshlist.cpp(5) : error C2248: ‘Mesh::vboHandle_’ : cannot access
    private member declared in class ‘Mesh’
  • mesh.h(10) : see declaration of ‘Mesh::vboHandle_’
  • mesh.h(8) : see declaration of ‘Mesh’
  • meshlist.cpp(5) : error C2100: illegal indirection
  • 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-03T01:35:16+00:00Added an answer on June 3, 2026 at 1:35 am

    Cyclic dependencies are explained in the other answers…

    Here comes the solution:

    In MeshList.h:

    • replace #include "Mesh.h" with the forward declaration class Mesh; (You don’t need the include here, because you only declare a pointer to a Mesh)

    In MeshList.cpp:

    • add #include "Mesh.h" to your includes (you need the declaration, because you use the Mesh)

    The last compile error, you mentioned is another problem:

    *mesh->vboHandle_ = 4;
    

    mesh is a pointer. Your code selects the member vboHandle_ and tries to dereference it (which fails). I suppose you mean:

    mesh->vboHandle_ = 4; // <-- no leading asterisk
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes that refer to each other, but obviously the compiler complains.
I have two classes and want to build a collection that contains a collection.
I have two classes that each need an instance of each other to function.
I have two classes that I would like to merge into a composite. These
I have two classes that I am testing (let's call them ClassA and ClassB).
I have two classes Order and Items I want a method like this class
I have two classes defined such that they both contain references to the other
I have two classes: public class Singleton{ private Singleton(){...} private static class InstanceHolder{ private
I have two classes class PopulationMember { public: void operationOnThisMember1(); void operationOnThisMember2(); ... private:
I have two classes(Book,Software) that inherit from the Product class. these two classes have

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.