Hello everyone,
I have been working on this for two days. I've been Googling a lot and couldn't come up with an solution. Any help would be appreciated.
I got the following errors and don't know how I should fix:
Severity Code File Project Description Line
Error C2027 C:\Users\PassionateProgrammer\Documents\Test\ProxyTest.cpp Proxy use of undefined type 'VaddV' 14
Severity Code File Project Description Line
Error (active) E0409 C:\Users\PassionateProgrammer\Documents\Test\ProxyTest.cpp Proxy function "operator+" returns incomplete type "VaddV" 14
Severity Code File Project Description Line
Error C2679 C:\Users\PassionateProgrammer\Documents\Test\ProxyTest.cpp Proxy binary '=': no operator found which takes a right-hand operand of type 'VaddV' (or there is no acceptable conversion) 14
class VaddV is a proxy and must not implement inside the class Vect2D.
Hello everyone,
I have been working on this for two days. I've been Googling a lot and couldn't come up with an solution. Any help would be appreciated.
I got the following errors and don't know how I should fix:
Severity Code File Project Description Line
Error C2027 C:\Users\PassionateProgrammer\Documents\Test\ProxyTest.cpp Proxy use of undefined type 'VaddV' 14
Severity Code File Project Description Line
Error (active) E0409 C:\Users\PassionateProgrammer\Documents\Test\ProxyTest.cpp Proxy function "operator+" returns incomplete type "VaddV" 14
Severity Code File Project Description Line
Error C2679 C:\Users\PassionateProgrammer\Documents\Test\ProxyTest.cpp Proxy binary '=': no operator found which takes a right-hand operand of type 'VaddV' (or there is no acceptable conversion) 14
class VaddV is a proxy and must not implement inside the class Vect2D.
#ifndef PROXY_H
#define PROXY_H
class Vect2D
{
public:
Vect2D(const Vect2D& tmp) = default;
Vect2D& operator =(const Vect2D& tmp) = default;
Vect2D() = default;
~Vect2D() = default;
Vect2D(constfloat inX, constfloat inY);
void setX(constfloat inX);
void setY(constfloat inY);
void set(constfloat inX, constfloat inY);
float getX() const;
float getY() const;
// -----------------------------------------------------------------------
// Rules:
//
// No implementation in Header
//
//
//
// Proxy is the only thing that can have the keyword "inline"
// inline only for subsitution resolving.. that's it
// No constructors or other operators... only proxy for substituion purpose
//
// No proxy implementation in header
// conversion operator needs to be implemented in CPP file
// proxy constructor are allowed in header (only exception)
// -----------------------------------------------------------------------
public:
float x;
float y;
};
class VaddV;
inline VaddV operator+(const Vect2D& a1, const Vect2D& a2);
#endif
ProxyTest.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include "Proxy.h"
int main()
{
volatilefloat v1 = 2.0f;
volatilefloat v2 = 3.0f;
Vect2D A;
A.set(0.0f, 0.0f);
Vect2D B;
B.setX(v1);
B.setY(v2);
Vect2D sum;
sum.set(0.0f, 0.0f);
sum = A + B;
}
// --- End of File ---------------
Your operator+ returns a VaddV object. A forward declaration won't suffice for the declaration of this at line 44 of Proxy.h; the compiler needs to be able to see the VaddV definition for it to be able to understand this declaration.
The VaddV definition should go into Proxy.h for this to work.