Mailinglist Archive: opensuse-programming (68 mails)

< Previous Next >
Re: [suse-programming-e] C++ compile problem. error in function
  • From: Jerry Feldman <gaf@xxxxxxx>
  • Date: Mon, 12 Jan 2004 16:10:45 -0500
  • Message-id: <20040112161045.5ce1f7e7@xxxxxxxxxxx>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 12 Jan 2004 15:17:40 -0500 (EST)
Trey Gruel <drathos-suse@xxxxxxxxxxxxxx> wrote:

> looking at the full code, i don't see why bill.stock is an array.
It's not.
struct BillLine
{
StockItem stock;
It is a single element.
bill.stock = stock[item];
should be a simple structure copy.
Actually, structure copies are bad things in C++. All structures are
classes, complete with constructors and destructors.
I wonder if the value of item is >= NUM_ITEMS, and what he is really
seeing is a bounds error.

Or, as I mentioned earlier, his intent may be to simply use a pointer.
In his code he is passing structures as arguments to functions.

Also I noticed that my static cast has a typo:
bill.stock = *<static_cast<StockItem *>(&stock[item]);

Should be:
bill.stock = *static_cast<StockItem *>(&stock[item]);

- --
Jerry Feldman <gaf@xxxxxxx>
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)

iD8DBQFAAw1V+wA+1cUGHqkRAuBCAJ0XIbuvL+q1mV+RmIH0hiGccXJLpwCfU/qZ
sj9zUdaKbj4d/AhL8t/pLQY=
=ZLP+
-----END PGP SIGNATURE-----

< Previous Next >