-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mon, 12 Jan 2004 18:56:41 -0000 "ged.suse" <ged.suse@ntlworld.com> wrote:
Structures are global and are as follows:
struct StockItem { int code; char desc[20]; float price; }stock[NUM_OF_ITEMS];
struct BillLine { StockItem stock; float weight; float cost; }bill_line[50]; <snip> /*line 213*/ bill.stock = stock[item]; cout << "Weight: ";
(+(i * 3508)))->BillLine::stock', which is of non-aggregate type ` StockItem[125]'
On Mon, 12 Jan 2004 14:06:09 -0500 (EST) Trey Gruel <drathos-suse@nightmoose.net> wrote: notice the difference between the two declarations of BillLine. the
problem you're having is becuase in the full code, you're trying to assign a single StockItem to an array of them without referencing a single array location. the second error has the same cause. you're trying to access the desc value but treating it as a single StockItem, not an array.
I think that Trey's comments are legitimate, but not the solution. bill.stock is a single instance of a stock item. I think you might be able to cast this: bill.stock = *<static_cast<StockItem *>(&stock[item]); What you apparently want to do is to copy a single instance. Or you can use the memcpy function. But, if the StockItem in the BillLine is really intended as a reference, then struct BillLine
{ StockItem *stock; float weight; float cost; }bill_line[50];
Then: bill.stock = &stock[item]; Now, bill.stock will point to the appropriate instance, Also, I did not check you code, but item must be in the range from 0 >= item < NUM_ITEMS. If item == NUM_ITEMS, then you are exceeding the bounds of the array. But, it appears that your code is really C being compiled with a C++ compiler. - -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQFAAv6P+wA+1cUGHqkRAmlUAJ9KmqSybC4qfDcZ+BMwcOvvd68QQwCdHCtC pCUtlu77rLwK6kJdETCGmu8= =7Xey -----END PGP SIGNATURE-----