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 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
Anxiety. A very common reason for this difficulty is that many people experience some degree of anxiety when meeting new people. This anxiety stems from a fear of being rejected or judged by others.
Common reasons why it is hard making friends are social anxiety, introversion, trust issues, lack of opportunity, and relocation. As we grow older, people are busy with work, family, or children.
Some kids develop it naturally at a young age, while others need more time. In some cases, kids simply haven't met anyone they can connect with. Different challenges can also get in the way. Some kids get too nervous or anxious to talk to others.
People need at least a little human contact in order to thrive, and true isolation can take a toll on your overall well-being. If you're not totally isolated, though, and your lack of friends doesn't trouble you, it can be perfectly fine to be satisfied with your own company.
When you compile Mesh.cpp
, it includes Mesh.h
, which includes MeshList.h
, which starts to include Mesh.h
but stops early because _MESH_H
is now defined. Then (back in MeshList.h
) there's a reference to Mesh
-- but that hasn't been declared yet. Hence, e.g., your C2143 error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With