Advertisement

Pointer casting and indirection is killing me!

Started by December 10, 2002 02:44 AM
12 comments, last by Alpha_ProgDes 21 years, 11 months ago
(*Mack)->name = name;

because *Mack is a pointer to a Truck.

It''s the same as

(**Mack).name = name;
last newbie/silly question of the night/day....

so this is legal also?

(*Mack)->name = name;

or should it be (*Mack).name = name; ???<br><br>so sorry for silly questions? this just confuses me so much. </i>

Beginner in Game Development?  Read here. And read here.

 

Advertisement
(*Mack).name = name;<br><br>In what context?<br>if Mack is an array of pointers to Truck it's correct. But then it will be more readable:<br>Mack->name = name;<br><br>The operators -> and [] are mere abbreviations (if aren't overloaded):<br> x->y is for (*x).y<br> <br> and x is for *(x + i)<br><br><br><br><br>edited because was fucking as italics<br><br><SPAN CLASS=editedby>[edited by - Pepe &#111;n December 10, 2002 7:33:12 AM]</SPAN>
In your example you must make sure that Truck is allocated before you access its **.

This topic is closed to new replies.

Advertisement