If you will place your definitions in this order then the code will be compiled
class Ball; class Player { public: void doSomething(Ball& ball); private: }; class Ball { public: Player& PlayerB; float ballPosX = 800; private: }; void Player::doSomething(Ball& ball) { ball.ballPosX += 10; // incomplete type error occurs here. } int main() { }
The definition of function doSomething requires the complete definition of class Ball because it access its data member.
In your code example module Player.cpp has no access to the definition of class Ball so the compiler issues an error.
Related Posts:
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Linker Error C++ “undefined reference ” [duplicate]
- What are the differences between a pointer variable and a reference variable in C++?
- Expression must have class type
- Why is enum class preferred over plain enum?
- Why am I getting this redefinition of class error?
- What are forward declarations in C++?
- Single class has a Class Redefinition Error
- C++ Linked List Node with class
- What does `*&` in a function declaration mean?
- (->) arrow operator and (.) dot operator , class pointer
- Pass a vector by reference C++
- Difference between const reference and normal parameter
- Separating class code into a header and cpp file
- how to define -std=c++11 as default in g++
- Pointer to incomplete class type is not allowed
- Why am I getting this redefinition of class error?
- no default constructor exists for class
- Is the practice of returning a C++ reference variable evil?
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- What are the differences between struct and class in C++?
- error C2011: ” : ‘class’ type redefinition
- The compiler is complaining about my default parameters?
- C++ Linked List Node with class
- Getting error: ISO C++ forbids declaration of with no type
- initial value of reference to non-const must be an lvalue
- error: member access into incomplete type : forward declaration of
- “Implicit instantiation of undefined template” when forward declaring template class
- “used without template parameters”
- Error: No instance of constructor matches the argument list
- expected constructor, destructor, or type conversion before ‘(’ token
- C++ Class ‘undeclared identifier”
- Base class undefined
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- What is the meaning of a C++ Wrapper Class?
- error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- Reference to non-static member function must be called
- Does C++11 have C#-style properties?
- C++ Return value, reference, const reference
- G++ undefined reference to class::function
- Creating an instance of class
- C++ pass an array by reference
- How to create a vector of class objects in C++?
- expected primary-expression before ‘]’ token
- Is null reference possible?
- Why can’t I make a vector of references?
- Is C++ Array passed by reference or by pointer?
- error C2039: ‘string’ : is not a member of ‘std’, header file problem
- istream and ostream problem – C++
- Struct with template variables in C++
- error: no member function declared in class
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- Error: invalid use of member in static member function
- What is the effect of extern “C” in C++?
- What exactly is the difference between “pass by reference” in C and in C++?
- What is `CString`?
- Difference between != and =! with an example(in C++)
- Unresolved external symbol in object files
- How to fix ‘No match for operator[]’ error (c++)
- std::cin.getline( ) vs. std::cin
- C++ error: terminate called after throwing an instance of ‘std::bad_alloc’
- Undefined reference to vtable
- How to get current time and date in C++?
- Writing a LinkedList destructor?
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- Creating a copy constructor for a linked list
- Is there a tab equivalent of std::endl within the standard library?
- Using the fstream getline() function inside a class
- Missing vc_runtimeminimum_x86.msi and installation won’t work
- I’m getting an error “invalid use of incomplete type ‘class map’
- How to convert C++ Code to C
- how to convert C# to C++
- What are helper functions in C++?
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- fatal error LNK1169: one or more multiply defined symbols found in game programming
- How to initialize a vector of pointers
- C++: Using ifstream with getline();
- How to add element to C++ array?
- Random not declared in scope
- What does the “Expected ‘(‘ for function-style cast or type construction” error mean?
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Comparing the values of char arrays in C++
- Win32 Console Application
- What does the fpermissive flag do?
- Convert char array to single int?
- https://stackoverflow.com/questions/3865946/error-generic-array-creation
- C++ variable has initializer but incomplete type?
- cin.ignore(numeric_limits
::max(), ‘\n’) - LLVM Compiler 2.0: Warning with “using namespace std;”
- C++ operator+ and operator+= overloading
- In c++ what does a tilde “~” before a function name signify?
- C++ Void Function with File Stream Error
- glibc detected : double free or corruption
- What is the best way to develop a C++ web application?
- How to install Visual Studio Build Tools 2010 on Visual Studio 2015 Community?
- Throwing out of range exception in C++
- Link error “undefined reference to `__gxx_personality_v0′” and g++ [duplicate]
- How to use bitmask?
- -Error reading characters of string