This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
struct RAII { | |
~RAII() { | |
char buf[1000]; | |
memset(buf, 'A', 1000); | |
} | |
}; | |
void thrower() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(int argc, char** argv) { | |
try { | |
char* p = new char[10485760000]; | |
delete [] p; | |
cout << "alloced!" << endl; | |
} catch(std::exception& e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
int main() { | |
bool b = false; | |
char buf[10]; | |
buf[0] = '\0'; | |
strcat(buf, "hello kittieeeeeeeeeeee!\n"); | |
//*((char*)&b) = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
int main() { | |
bool b = false; | |
*((char*)&b) = 2; | |
if(b == true) printf("b is true!\n"); | |
if(b == false) printf("b is NOT true!\n"); | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use %ERRORLEVEL% to get the result | |
#include <iostream> | |
#include <vector> | |
#include <list> | |
#include <map> | |
using namespace std; | |
struct A { | |
A(int in = 5) : a(in) { cout << "ctor!" << endl; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct A { | |
int a; | |
}; | |
struct B { | |
int b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use %ERRORLEVEL% to see result of program | |
#include <iostream> | |
#include <memory> | |
using namespace std; | |
struct A1 {}; | |
struct A2 {}; | |
struct A3 {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <typeinfo> | |
struct A { | |
//virtual ~A(){} //#uncomment to enable rtti for this inheritance hierarchy | |
}; | |
struct B : A {}; | |
void func(A* a1, A* a2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// OUTPUT IS: | |
// 500059 | |
// 500058 | |
// 2891316 | |
struct A { | |
void f() { | |
int a; // to take the stack address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// OUTPUT IS: | |
// 500059 | |
// 500058 | |
// 2891316 | |
struct A { | |
void f() { | |
int a; // to take the stack address |