Content deleted Content added
m Sp |
|||
Line 83:
the basic problem is that the constructor is a peculiar function; when it starts off, there is no object, only raw memory. and by the time it finishes, you have a fully initialized object. therefore i. the constructor cannot be called on an object ii. however, it needs to access (and initialize) non-static members. this makes calling the constructor directly an error. the solution is the placement form of operator new.
this operator is implemented as:<source lang="cpp" enclose=div>
inline void* operator new( size_t sz, void* here )
Line 92 ⟶ 90:
inline void* operator new[]( size_t sz, void* here )
{ return here ; }
</source
in your case, using this is not required as an int is pod, it has a trivial constructor. if you want to use it, you could use it this way:<source lang="cpp" enclose=div>▼
▲in your case, using this is not required as an int is pod, it has a trivial constructor. if you want to use it, you could use it this way:
for( int i = 0; i < MAX_PIXELS; i++ )
|