锘??xml version="1.0" encoding="utf-8" standalone="yes"?>日本道色综合久久影院,久久伊人精品一区二区三区,91精品国产色综久久http://www.shnenglu.com/foobar/zh-cnWed, 07 May 2025 18:42:08 GMTWed, 07 May 2025 18:42:08 GMT60Advanced Test in C: The 0x10 Best Questions for C Programmers http://www.shnenglu.com/foobar/archive/2007/12/03/37683.htmlfoobarfoobarMon, 03 Dec 2007 07:12:00 GMThttp://www.shnenglu.com/foobar/archive/2007/12/03/37683.htmlhttp://www.shnenglu.com/foobar/comments/37683.htmlhttp://www.shnenglu.com/foobar/archive/2007/12/03/37683.html#Feedback0http://www.shnenglu.com/foobar/comments/commentRss/37683.htmlhttp://www.shnenglu.com/foobar/services/trackbacks/37683.htmlAdvanced Test in C: The 0x10 Best Questions for C Programmers
]]>闅愯棌http://www.shnenglu.com/foobar/archive/2007/11/23/37221.htmlfoobarfoobarFri, 23 Nov 2007 12:44:00 GMThttp://www.shnenglu.com/foobar/archive/2007/11/23/37221.htmlhttp://www.shnenglu.com/foobar/comments/37221.htmlhttp://www.shnenglu.com/foobar/archive/2007/11/23/37221.html#Feedback0http://www.shnenglu.com/foobar/comments/commentRss/37221.htmlhttp://www.shnenglu.com/foobar/services/trackbacks/37221.html
#include <iostream.h> class Base { public: virtualvoid f(float x){ cout <<"Base::f(float) "<< x << endl; } void g(float x){ cout <<"Base::g(float) "<< x << endl; } void h(float x){ cout <<"Base::h(float) "<< x << endl; } }; class Derived : public Base { public: virtualvoid f(float x){ cout <<"Derived::f(float) "<< x << endl; } void g(int x){ cout <<"Derived::g(int) "<< x << endl; } void h(float x){ cout <<"Derived::h(float) "<< x << endl; } };
void main(void) { Derived d; Base *pb =&d; Derived *pd =&d; // Good : behavior depends solely on type of the object pb->f(3.14f); // Derived::f(float) 3.14 pd->f(3.14f); // Derived::f(float) 3.14 // Bad : behavior depends on type of the pointer pb->g(3.14f); // Base::g(float) 3.14 pd->g(3.14f); // Derived::g(int) 3 (surprise!) // Bad : behavior depends on type of the pointer pb->h(3.14f); // Base::h(float) 3.14 (surprise!) pd->h(3.14f); // Derived::h(float) 3.14 }
class Base { public: void f(int x); }; class Derived : public Base { public: void f(char*str); }; void Test(void) { Derived *pd =new Derived; pd->f(10); // error //why? just imagine multiple inheritance }
]]>atexit -- function to be executed on exithttp://www.shnenglu.com/foobar/archive/2007/11/15/36729.htmlfoobarfoobarThu, 15 Nov 2007 15:47:00 GMThttp://www.shnenglu.com/foobar/archive/2007/11/15/36729.htmlhttp://www.shnenglu.com/foobar/comments/36729.htmlhttp://www.shnenglu.com/foobar/archive/2007/11/15/36729.html#Feedback0http://www.shnenglu.com/foobar/comments/commentRss/36729.htmlhttp://www.shnenglu.com/foobar/services/trackbacks/36729.html
int atexit ( void ( * function ) (void) ); <cstdlib>
The function pointed by the function pointer argument is called when the program terminates normally.
If more than one atexit function has been specified by different calls to this function, they are all executed in reverse order as a stack, i.e. the last function specified is the first to be executed at exit.
One single function can be registered to be executed at exit more than once.
C++ implementations are required to support the registration of at least 32 atexit functions.
Parameters
function
Function to be called. The function has to return no value and accept no arguments.
Return Value
A zero value is returned if the function was successfully registered, or a non-zero value if it failed.
Example
/* atexit example */#include <stdio.h>#include <stdlib.h>void fnExit1 (void)
{
puts ("Exit function 1.");
}
void fnExit2 (void)
{
puts ("Exit function 2.");
}
int main ()
{
atexit (fnExit1);
atexit (fnExit2);
puts ("Main function.");
return 0;
}
]]>Gotchas in the C++ programing languagehttp://www.shnenglu.com/foobar/archive/2007/06/04/25442.htmlfoobarfoobarMon, 04 Jun 2007 03:11:00 GMThttp://www.shnenglu.com/foobar/archive/2007/06/04/25442.htmlhttp://www.shnenglu.com/foobar/comments/25442.htmlhttp://www.shnenglu.com/foobar/archive/2007/06/04/25442.html#Feedback0http://www.shnenglu.com/foobar/comments/commentRss/25442.htmlhttp://www.shnenglu.com/foobar/services/trackbacks/25442.htmlInitializer lists
In C++, it is the order of the class inheritance and of the member variables that determine the initialization order, not the order of an initializer list:
#include <iostream> class CSomeClass { public: CSomeClass(int n) { std::cout <<"CSomeClass constructor with value "; std::cout << n << std::endl; } }; class CSomeOtherClass { public: CSomeOtherClass() //In this example, despite the list order, : obj2(2), obj1(1) //obj1 will be initialized before obj2. { //Do nothing. } private: CSomeClass obj1; CSomeClass obj2; }; int main(void) { CSomeOtherClass obj; return0; }