What is the Standard Template Library (STL)?
A library of container templates approved by the ANSI committee for
inclusion in the standard C++ specification.
A programmer who then launches into a discussion of the generic
programming model, iterators, allocators, algorithms, and such, has a
higher than average understanding of the new technology that STL brings
to C++ programming.
Describe run-time type identification.
The ability to determine at run time the type of an object by using the
typeid operator or the dynamic_cast operator.
What problem does the namespace feature solve?
Multiple providers of libraries might use common global identifiers
causing a name collision when an application tries to link with two or
more such libraries. The namespace feature surrounds a library’s
external declarations with a unique namespace that eliminates the
potential for those collisions.
This solution assumes that two library vendors don’t use the same
namespace identifier, of course.
Are there any new intrinsic (built-in) data types?
Yes. The ANSI committee added the bool intrinsic type and its true and
false value keywords.
Will the following program execute?
void *vptr = (void *) malloc(sizeof(void));
It will throw an error, as arithmetic operations cannot be performed on
It will not build as sizeof cannot be applied to void* ( error “Unknown
How can it execute if it won’t even compile? It needs to be int main,
not void main. Also, cannot increment a void *.
According to gcc compiler it won’t show any error, simply it executes.
but in general we can’t do arthematic operation on void, and gives size
of void as 1
The program compiles in GNU C while giving a warning for “void main”.
The program runs without a crash. sizeof(void) is “1? hence when vptr++,
the address is incremented by 1.
Regarding arguments about GCC, be aware that this is a C++ question, not
C. So gcc will compile and execute, g++ cannot. g++ complains that the
return type cannot be void and the argument of sizeof() cannot be void.
It also reports that ISO C++ forbids incrementing a pointer of type
voidp.c: In function `int main()’:
voidp.c:4: error: invalid application of `sizeof’ to a void type
voidp.c:4: error: `malloc’ undeclared (first use this function)
voidp.c:4: error: (Each undeclared identifier is reported only once for
each function it appears in.)
voidp.c:6: error: ISO C++ forbids incrementing a pointer of type `void*’
But in c, it work without problems
char *cptr = 0?2000;
long *lptr = 0?2000;
printf(” %x %x”, cptr, lptr);
Will it execute or not?
For Q2: As above, won’t compile because main must return int. Also,
0×2000 cannot be implicitly converted to a pointer (I assume you meant
0×2000 and not 0?2000.)
Compile with VC7 results following errors:
error C2440: ‘initializing’ : cannot convert from ‘int’ to ‘char *’
error C2440: ‘initializing’ : cannot convert from ‘int’ to ‘long *’
Not Excute if it is C++, but Excute in C.
[$]> g++ point.c
point.c: In function `int main()’:
point.c:4: error: invalid conversion from `int’ to `char*’
point.c:5: error: invalid conversion from `int’ to `long int*’
[$] etc > gcc point.c
point.c: In function `main’:
point.c:4: warning: initialization makes pointer from integer without a
point.c:5: warning: initialization makes pointer from integer without a
[$] etc > ./a.exe