Nov 22, 2009

Confusion With Structs

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Programming General > C, C++ & Visual C++

Confusion With Structs

xboxrulz
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,
xboxrulz

 

 

 


Comment/Reply (w/o sign-up)

wutske
If you pass a struct, you need to tell your program that it's a struct, so
CODE
void posmath (POS sales, int *intCount, double *total, double *stotal){


should be
CODE
void posmath (struct POS sales, int *intCount, double *total, double *stotal){


Also, because you're working in C++, you need to declare what namespace you use wink.gif

Comment/Reply (w/o sign-up)

xboxrulz
alright got it, thanks.

i did declare my namespace in my custom stdheader.h where I imported everything.

xboxrulz

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)



*SIMILAR VIDEOS*
Searching Video's for Confusion, With, Structs
advertisement



Confusion With Structs

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com