TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JOSHUA BOEHME
from: JERRY COFFIN
date: 1997-04-23 09:47:00
subject: Pointer Arrays

On (20 Apr 97) Joshua Boehme wrote to All...
 JB> I am working on a program where I need an array of variable-size
 JB> arrays.  However, whenever I try to create one, I get either an
 JB> invalid indirection or syntax error.
 JB> Here is the code fragment:
[ code elided ]
 JB> Any thoughts? The rest of the program works fine (so far...).
A number of them.  First of all, I'd consider using an array class
instead of using raw arrays.  I suspect this will simplify things
considerably.  Second, I'd take a hard look at exactly what you're
doing.  Lines like:
pointer[data[id[j]].controller - 1][k[data[id[j]].controller - 1]] = id[j];
easily qualify as excessively complex, at least IMO.  It takes a great
deal of work to figure out exactly what that's supposed to accomplish.
If nothing else, doing something like:
    int &player = id[j].controller-1;
    pointer[data[player]][k[player]] = id[j];
can help make things considerably easier to read.  However, even that's
right at about the limit of what I'd consider readable in a single line.
If possible, I'd simplify things even more.  Without the rest of your
code to look at, it's difficult to figure out exactly what this code is
doing, or how it could be simplified.
Second, I'd consider using some classes instead of simple structs.
Using classes can often help you to partition the code, so no one part
gets excesively complex.  Again, without knowing more about what you're
doing, it's hard to say exactly how you'd want to go about this.
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.