topical media & game development
professional-program-12-Const-Const.c
? /
professional-program-12-Const-Const.c
include <cstdlib>
const double PI = 3.14159;
class BigClass;
void doSomething(const BigClass& arg)
{
// implementation here
}
void constIntOne()
{
const int* ip;
ip = new int[10];
// ip[4] = 5; // DOES NOT COMPILE!
}
void constIntTwo()
{
int const * ip;
ip = new int[10];
// ip[4] = 5; // DOES NOT COMPILE!
}
void constPtrOne()
{
int* const ip = NULL;
// ip = new int[10]; // DOES NOT COMPILE!
ip[4] = 5;
}
void constIntPtrOne()
{
int const * const ip = NULL;
}
void constIntPtrTwo()
{
const int * const ip = NULL;
}
void manyLevelConst()
{
const int * const * const * const ip = NULL;
}
int main(int argc, char** argv)
{
int* ip;
ip = new int[10];
ip[4] = 5;
int z;
const int& zRef = z;
// zRef = 4; // DOES NOT COMPILE
return (0);
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.