Question:
What do the following C++ code snippets do?
Stochastic
2010-10-15 07:56:02 UTC
I am new to advanced C++ code, so I need some help on understanding a few things.

Code snippet 1: (Why the []??)

delete [] m_pParm;

Code snippet 2: (What is the _DEXPORT?? I assume this is a function that returns a double, but could _DEXPORT be some kind of object that gets returned instead of a double??)

double _DEXPORT Circ(int np, double **pdAc, double **pdV, double *X0,
double &R, e_approx approx=lsq);
Three answers:
JoelKatz
2010-10-15 08:01:56 UTC
In code snippet 1, the '[]' means that m_pParm is an array. You allocate an array with 'new[]' and delete it with 'delete[]'.



In code snippet 2, the '_DEXPORT' is defined someplace else in the code. Most likely, it's used to indicate that the function should be exported (made available to other code).



This is often important on platforms that support more than one calling convention. Functions only called inside a single program can use any calling convention -- whatever is fastest for that particular use. But functions called by other programs or libraries have to use the platform's standard calling convention.
green meklar
2010-10-15 10:30:17 UTC
In snippet 1, the [] is there because m_pParm is apparently a pointer to an array, and the program is supposed to delete the array. In order to do this, the [] part is necessary, it tells the compiler how to interpret that delete statement.



Snippet 2 I'm not sure about. I haven't seen anything that looks like that before.
mokriski
2016-10-19 01:30:25 UTC
Case demands a continuing expression, this is incredibly so simple as that. the reason of it particularly is probable to keep away from an invalid change assertion wherein 2 case statements have the comparable fee, which isn't allowed. as an occasion if your ok have been equivalent to 3 the change assertion could incorporate 2 cases of "case 3:" that may't be resolved. wish this enables! Edit: some time-honored coding suggestion - this is totally priceless to get used to perfect formatting and indenting your code, as this makes explaining it to others and soliciting for help *a techniques* much less puzzling. good luck :)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...