Thursday 15 March 2012

C++ -- Pointers to Arrays -- Arrays of Pointers -


I have noticed that it has created confusion for many people, but here are some steps to read and read cplusplus tutorials. After my brain was still fried

Suppose I have the following variables in the header file -

  Int number of offline points; D3DXVECTOR3 * line; // This is confused as to  

, then in the implementation C ++ file I initialize it as the following -

  / / Started in both constructor numbersOffline pin = 25; Line = new D3DXVECTOR3 [numpoint]; // array of indicators?  

How does my line variable now show?

As far as I can read from the links on staxahovarflow, I can indicate that it should represent an array. I then read the following ...

(1)

... where (a) the arrows of pointers , And (b) Pointer to Arrays both discuss. It has left me confused once again because they both work the same way.

The fact is that I define my pointers in a different place where I allocate (right?) They think where my confusion is from What do I do right Is this an array of pointers for D3VTttR3 objects?

to finish - If there is information about a line segment in the variable line, then am I making an array of line segments? I currently have the following -

  // header file int numberoffline section; D3DXVECTOR3 ** Line Collection; // Pointer array - each of which points for // pointers array? // CPP file numberoffline class = 8; // For constructor (i = 0; i & lt; numerally offline class; i ++) // initialization {// and allocation is correct? Lineclass [i] = new D3xxactor * [nm points]; / / Y / N} // Memory collection for line collection (zero) start line partitions (startpoint, endpoints) // instead of generating a line segment {// can return proxy array! = Numberoffline points line [sent ++] = interpolate (start page, end point, time-takt)) // to generate an array of pseudo line lines! = Numberoffline line demographics [posted ++] = line}  

Any help is highly appreciated.

  int numberoffline points; D3DXVECTOR3 * line; // Confused as to what it is // the initial line in both constructor numbers = 2; Line = new D3DXVECTOR3 [numpoint]; // array of indicators?  

line is an array D3DXVECTOR3 . This will be an array of indicators if D3DVECTOR3 is itself an indicator, though. Since I do not know C + + D header very well, I'm not sure.

  D3dAquactor 3 ** Line Collection;  

There is an array of indicators, each indicator is likely to be an indicator in a line (i.e., an array of D3DXVECTOR3 ).

You have to have two options, randomly, to set each entry on the same line in the lineCollection . It is safe if you know that the lines do not change Going (and can not be freed), or if they change, you want to see the changes inside your collection.

The second option will be to create a new array for each entry in the lineCollection , and copy the copies to each new array from each line .

There is no correct answer, it depends on your desired functionality.


No comments:

Post a Comment