![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
passing locally defined user type to function from functionIf I prototype and call a function from within another function, passing a locally defined user type as a variable, as in:
CPP / C++ / C Code:
I get the following errors: Quote:
(note that the line numbers above don't correspond to the code posted) How do I get this to work? Do I have to use the scope resolution operator somehow? Do I have to define struct hand somewhere other than within the local function? I know I can define hand as a global variable but should I or is there another way? |
|||
|
#2
|
|||
|
|||
Re: passing locally defined user type to function from functionQuote:
The definition for the struct must be visible wherever it is used. By declaring it inside of function deal(), it isn't known anywhere else. You could do something like this CPP / C++ / C Code:
Note that the instance pokerHand is still local to its function (it's not a global or file scope variable). Struct definitions and other typedef statements are typically placed in headers, but they don't have to be. Regards, Dave |
Recent GIDBlog
Updates On The All New Toyota VIOS - Part III by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Database Program | goldfish | C Programming Language | 6 | 13-May-2006 13:12 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| [GIM] gim.h | dsmith | C Programming Language | 0 | 18-Jan-2005 08:48 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 03:38 |
| Revising Script style ?????? | pepee | MySQL / PHP Forum | 4 | 14-Apr-2004 04:59 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The