Error C2027 Use Of Undefined Type Class
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Use Of Undefined Type Class C++
and policies of this site About Us Learn more about Stack Overflow c++ use of undefined type forward declaration the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Error C2027 Use Of Undefined Type Template
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it c2027 forward declaration only takes a minute: Sign up Use of undefined type [duplicate] up vote 6 down vote favorite This question already has an answer here: When can I use a forward declaration? 12 answers #include
here for a quick overview of the site Help Center
Use Of Undefined Type Pimpl
Detailed answers to any questions you might have Meta class type redefinition c++ Discuss the workings and policies of this site About Us Learn more about Stack Overflow
Pointer To Incomplete Class Type Is Not Allowed
the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x http://stackoverflow.com/questions/18284678/use-of-undefined-type Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up use of undefined type c++ , class [duplicate] up vote -1 down vote favorite This question already has http://stackoverflow.com/questions/33556708/use-of-undefined-type-c-class an answer here: Resolve header include circular dependencies 8 answers I have a problem, the Rectangle class is not working properly in TwoDimTree.h For example, "Rectangle Extent;" seems like working ,but when i try to use it it says no member class found. I want to use it like "Extent.get_Top;" , but i cant make it. Also in the error list i got. Error 7 error C2027: use of undefined type 'Rectangle' My headers are below.I really couldn't find my mistake.Thanks for the help. My TwoDimTree.h #include
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 https://msdn.microsoft.com/en-us/library/6c2dk0ah.aspx Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. C/C++ Building Reference C/C++ http://www.cplusplus.com/forum/beginner/31788/ Build Errors Compiler Errors C2001 through C2099 Compiler Errors C2001 through C2099 Compiler Error C2027 Compiler Error C2027 Compiler Error C2027 Compiler Error C2001 Compiler Error C2002 Compiler Error use of C2003 Compiler Error C2004 Compiler Error C2005 Compiler Error C2006 Compiler Error C2007 Compiler Error C2008 Compiler Error C2009 Compiler Error C2010 Compiler Error C2011 Compiler Error C2012 Compiler Error C2013 Compiler Error C2014 Compiler Error C2015 Compiler Error C2017 Compiler Error C2018 Compiler Error C2019 Compiler Error C2020 Compiler Error C2021 Compiler Error C2022 Compiler Error C2026 Compiler use of undefined Error C2027 Compiler Error C2028 Compiler Error C2030 Compiler Error C2032 Compiler Error C2033 Compiler Error C2034 Compiler Error C2036 Compiler Error C2039 Compiler Error C2040 Compiler Error C2041 Compiler Error C2042 Compiler Error C2043 Compiler Error C2044 Compiler Error C2045 Compiler Error C2046 Compiler Error C2047 Compiler Error C2048 Compiler Error C2050 Compiler Error C2051 Compiler Error C2052 Compiler Error C2053 Compiler Error C2054 Compiler Error C2055 Compiler Error C2056 Compiler Error C2057 Compiler Error C2058 Compiler Error C2059 Compiler Error C2060 Compiler Error C2061 Compiler Error C2062 Compiler Error C2063 Compiler Error C2064 Compiler Error C2065 Compiler Error C2066 Compiler Error C2067 Compiler Error C2069 Compiler Error C2070 Compiler Error C2071 Compiler Error C2072 Compiler Error C2073 Compiler Error C2074 Compiler Error C2075 Compiler Error C2077 Compiler Error C2078 Compiler Error C2079 Compiler Error C2081 Compiler Error C2082 Compiler Error C2083 Compiler Error C2084 Compiler Error C2085 Compiler Error C2086 Compiler Error C2087 Compiler Error C2088 Compiler Error C2089 Compiler Error C2090 Compiler Error C2091 Compiler Error C2092 Compiler Error C20
Class "A" have a pointer to the original "creator object" of class "B" so they can access the original instance. The file looks a bit like this: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class B; class A { public: A() : _p(NULL) {} A(B* p) : _p(p) {} void TestFunc(int val) { _p->SetVal(val); } private: B* _p; }; class B { public: B(int v) : val(v) { s =A(this); } void SetVal(int v) { val = v; } void TestFunc(int val) { s.TestFunc(val); } private: A s; int val; }; However this gives me a compile error: 1>X\main.cpp(9) : error C2027: use of undefined type 'B' 1> X\main.cpp(2) : see declaration of 'B' Causes/how to create this? Nov 19, 2010 at 2:02pm UTC filipe (1165) _p->SetVal(val); You can't inline this just with a forward declaration. Remember, a forward declaration knows nothing about the class, it only allows you to use pointers or references, not methods. EDIT: -Objects of Class "A" have a pointer to the original "creator object" of class "B" so they can access the original instance. Also notice this shouldn't be necessary at all. If A has a pointer to an object of type B, A should know how to manipulate B, but B shouldn't know anything about A. Last edited on Nov 19, 2010 at 2:04pm UTC Nov 19, 2010 at 2:15pm UTC paul23 (22) @filipe: I'm afraid I don't fully understand what you are saying there (in the edit). As you can see in the "example": "A" can manipulate "B", however "A" ought to be accessed only from "B".. Let's put it more into english words: Suppose I have a "Car" (object "B").. That care has a certain "state" (object A) which defines what it is doing (parking, driving, etc).. Then what I would like to do is: let "Car" call: "State.doit()".. State.doit should then access the car object who called the function & update the car object (position, speed etc). Nov 19, 2010 at 2:57pm UTC filipe (1165) Such simple states could be held in an enumeration: 1
2
3
4
5
6
7
8
9
class Car { public: