In the new issue o
How do New Yorkers
Terry is known for
The invention rela
The new year has b
Mozilla has been t
The present invent
The goal of this p
Q: How to use ng-
Bisphenol A and lo

Souls on Ice Soul
Category: Blogging
You don’t have to
Q: Difference bet
[Influence of high
Safety The Office
A high school stud
Influence of the n
Hirschsprung disea
Q: How to create
// (C) Copyright John Maddock 2006. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include "../memory" //[example_function #include using std::cout; int main () { // Create a block with an initializer. // Note that we're using a static data member, which will be allocated in the data area, // so we'll have to use malloc to obtain a pointer to the data. // The contents of the memory block are copied, so that if it was also a managed type, // it would be copied. int x = 7; char *p = (char *)(malloc(sizeof(int))); *p = x; // Invoke an overloaded function, note that it is not a template. // Since there is only one parameter, we can omit the template parameter list. cout << x << '\n'; // Invoke a templated overloaded function. cout << f(&x) << '\n'; // Print the memory block and free it. cout << "Block contains:\n"; for(char *q = (char *)x; q != p; q++) cout << ' ' << *q; cout << '\n'; free(p); } //] void f(int* x) { cout << "Inside function!\n"; } //[fcontext_function #include using std::cout; int main () { // Create a block with an initializer. // Note that we're using a static data member, which will be allocated in the data area, // so we'll have to use malloc to obtain a pointer to the data. // The contents of the memory block are copied, so that if it was also a managed type, // it would be copied. int x = 7; char *p = (char *)(malloc(sizeof(int))); *p = x; // Invoke an overloaded function, note that it is not a template. // Since there is only one parameter, we can omit the template parameter list. cout << x << '\n'; // Invoke a templated overloaded function. f(&x); // Print the memory block and free it. cout << "Block contains:\n"; for(char *q = (char *)x; q != p; q++) cout << ' ' << *q; cout << '\n'; free(p); } //] void f(int* x) { cout << "Inside function!\n"; } //[class_function class X { // Create a block with an initializer. // Note that we're using a static data member, which will be allocated in the data area, // so we'll have to use malloc to obtain a pointer to the data. // The contents of the memory block are copied, so that if it was also a managed type, // it would be copied. int x; }; //] class X { // Create a block with an initializer. // Note that we're using a static data member, which will be allocated in the data area, // so we'll have to use malloc to obtain a pointer to the data. // The contents of the memory block are copied, so that if it was also a managed type, // it would be copied. int x; }; //] //[class_data_member_template template class MyClass { T m; }; //] //[class_class_data_member_template template class MyClass2 { T m; }; //] //[class_private_data_member_template template class MyPrivateClass { T m; public: MyPrivateClass(T a):m(a){} }; //] //[class_member_template_definition_and_declaration template void member(T); template void member(T) { } //] template void X::member(T x) { } //[class_member_definition_and_declaration template void X::member(T x) { } //] template void member(T x) { } //[template_declaration //] template