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 <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 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 <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
#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 <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> | |
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 <cstdio> | |
#include <cstring> | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
enum class Crap { | |
A = 0, | |
B, | |
C, |
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 <cstdlib> | |
#include <iostream> | |
using namespace std; | |
struct RAII { | |
RAII() { cout << "ctor" << endl; } | |
~RAII() { cout << "dtor" << endl; } | |
}; | |
RAII global; // dtor WILL be called! |
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> | |
template <class F, class... Args> | |
void for_each_argument(F f, Args&&... args) { | |
[](...){}((f(std::forward<Args>(args)), 0)...); | |
} | |
void print(int in) { | |
std::cout << in << std::endl; | |
} |