c++ pointer to pointer to pointer to pointer

Started by
11 comments, last by Anon Mike 15 years, 10 months ago
Hello. Have any of you found any practical use of **** - pointer to pointer to pointer to pointer? If you did probably to confuse anyone reading your code. Or else?
Advertisement
Nope.
And when you think of it. **** looks like censured swearing
A linked list is a 'Node **********...*node'.

Quote:If you did probably to confuse anyone reading your code.


Such syntax makes me want to do painful things to the author of the code.
char **** you;
const int **** must_stop;
The idea of the Three Star Programmer applies :)
A four-dimensional lattice to simulate quantum chromodynamics -- http://en.wikipedia.org/wiki/Lattice_QCD

However, vector<vector<vector<vector<type>>>> lattice; might be a better choice, in order to avoid potential memory leaks.

Either way, the usage syntax is not confusing beyond the allocation stage. One can use array notation for either pointer or vector cases, ex: lattice[t][x][y][z].whatever = 0;

**** Edit: See sneftel's response below (and my response to that) for a better solution.

[Edited by - taby on June 11, 2008 12:18:07 PM]
Quote:Original post by taby
A four dimensional lattice to simulate quantum chromodynamics -- http://en.wikipedia.org/wiki/Lattice_QCD

However, vector<vector<vector<vector<type>>>> lattice; might be a better choice.


vector<type>, with appropriate subscripting, would be an even better choice. Simulating multidimensional grids with nested one-dimensional containers is inefficient and wasteful.
Quote:Original post by Sneftel
Quote:Original post by taby
A four dimensional lattice to simulate quantum chromodynamics -- http://en.wikipedia.org/wiki/Lattice_QCD

However, vector<vector<vector<vector<type>>>> lattice; might be a better choice.


vector<type>, with appropriate subscripting, would be an even better choice. Simulating multidimensional grids with nested one-dimensional containers is inefficient and wasteful.


Ah yes, good point.

In that case, it would work out to something like:

vector<type> lattice;
lattice.resize(t_size*x_size*y_size*z_size);

size_t index = t*x_size*y_size*z_size + x*y_size*z_size + y*z_size + z;

lattice[index].whatever = 0;

It's been a while since I've done anything like this.

This topic is closed to new replies.

Advertisement