Computer Science Canada C++ Struct Calling Confusion |
Author: | deltatux [ Wed Jan 21, 2009 10:08 pm ] |
Post subject: | C++ Struct Calling Confusion |
Alright, I'm getting errors and it's confusing me on how to declare and pass a struct. http://pastebin.ca/1315254 The error I'm getting is: Quote: 1>------ Build started: Project: Workshop2, Configuration: Debug x64 ------
1>Compiling... 1>libpos.cpp 1>.\libpos.cpp(24) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(24) : error C2228: left of '.taxable' must have class/struct/union 1>.\libpos.cpp(25) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(25) : error C2228: left of '.ftax' must have class/struct/union 1>.\libpos.cpp(25) : error C2676: binary '[' : 'POS' does not define this operator or a conversion to a type acceptable to the predefined operator 1>.\libpos.cpp(25) : error C2228: left of '.price' must have class/struct/union 1>.\libpos.cpp(26) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(26) : error C2228: left of '.ptax' must have class/struct/union 1>.\libpos.cpp(26) : error C2676: binary '[' : 'POS' does not define this operator or a conversion to a type acceptable to the predefined operator 1>.\libpos.cpp(26) : error C2228: left of '.price' must have class/struct/union 1>.\libpos.cpp(28) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(28) : error C2228: left of '.ftax' must have class/struct/union 1>.\libpos.cpp(29) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(29) : error C2228: left of '.ptax' must have class/struct/union 1>.\libpos.cpp(31) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(31) : error C2228: left of '.quantity' must have class/struct/union 1>.\libpos.cpp(31) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(31) : error C2228: left of '.price' must have class/struct/union 1>.\libpos.cpp(32) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(32) : error C2228: left of '.quantity' must have class/struct/union 1>.\libpos.cpp(32) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(32) : error C2228: left of '.ftax' must have class/struct/union 1>.\libpos.cpp(32) : error C2027: use of undefined type 'POS' 1> d:\devel\c++\workshop2\workshop2\pointofsales.h(19) : see declaration of 'POS' 1>.\libpos.cpp(32) : error C2228: left of '.ptax' must have class/struct/union 1>pointofsales.cpp 1>.\pointofsales.cpp(37) : error C2676: binary '[' : 'POS' does not define this operator or a conversion to a type acceptable to the predefined operator 1>.\pointofsales.cpp(37) : error C2228: left of '.quantity' must have class/struct/union 1>.\pointofsales.cpp(46) : error C2664: 'posmath' : cannot convert parameter 1 from 'POS' to 'POS *' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>.\pointofsales.cpp(49) : error C2065: 'ftax' : undeclared identifier 1>.\pointofsales.cpp(50) : error C2065: 'ptax' : undeclared identifier 1>Generating Code... 1>Compiling... 1>main.cpp 1>Generating Code... 1>Build log was saved at "file://d:\devel\c++\Workshop2\Workshop2\x64\Debug\BuildLog.htm" 1>Workshop2 - 29 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Please help. Thanks, deltatux |
Author: | A.J [ Wed Jan 21, 2009 10:36 pm ] |
Post subject: | Re: C++ Struct Calling Confusion |
could you show me a copy of the code that you tried to compile (or is that what the link you provided is for?) |
Author: | deltatux [ Wed Jan 21, 2009 10:38 pm ] |
Post subject: | RE:C++ Struct Calling Confusion |
the link shows the code. and it's an Not For Work code (since some guy told me it's a requirement for GPL'd code here....) Thanks, deltatux |
Author: | A.J [ Wed Jan 21, 2009 10:40 pm ] | ||||
Post subject: | Re: C++ Struct Calling Confusion | ||||
k, i think ur problem is this :
it should instead be :
|
Author: | deltatux [ Wed Jan 21, 2009 11:00 pm ] |
Post subject: | RE:C++ Struct Calling Confusion |
nevermind, I fixed it with my friend's suggestion. Just by moving the struct to the header, it fixed it. Now, I'm getting another LNK2019 error. 1>pointofsales.obj : error LNK2019: unresolved external symbol "void __cdecl posmath(struct POS,int *,double *,double *)" (?posmath@@YAXUPOS@@PEAHPEAN2@Z) referenced in function "void __cdecl initPOS(void)" (?initPOS@@YAXXZ) 1>D:\devel\c++\Workshop2\x64\Debug\Workshop2.exe : fatal error LNK1120: 1 unresolved externals deltatux |
Author: | A.J [ Thu Jan 22, 2009 7:29 am ] |
Post subject: | Re: C++ Struct Calling Confusion |
can u show me what u fixed? |
Author: | DemonWasp [ Thu Jan 22, 2009 9:43 am ] | ||
Post subject: | Re: RE:C++ Struct Calling Confusion | ||
deltatux @ Wed Jan 21, 2009 11:00 pm wrote: 1>pointofsales.obj : error LNK2019: unresolved external symbol "void __cdecl posmath(struct POS,int *,double *,double *)" (?posmath@@YAXUPOS@@PEAHPEAN2@Z) referenced in function "void __cdecl initPOS(void)" (?initPOS@@YAXXZ)
1>D:\devel\c++\Workshop2\x64\Debug\Workshop2.exe : fatal error LNK1120: 1 unresolved externals This error message is telling you it can't find the method:
Where is that function declared, where is it defined? Are you sure both are being included properly? Are you sure the argument lists match exactly? |