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 <vector> | |
#include <iostream> | |
using namespace std; | |
int main() { | |
{ | |
size_t cap = 0; | |
vector<int> v; | |
for(int i = 0; i < 20; i++) { |
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 { | |
A() : data(0) {} | |
virtual void doStuff() { | |
data++; | |
cout << "A" << 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 { | |
void a() { cout << "a()" << endl; } | |
void a(int in) { cout << "a(int)" << endl; } | |
}; | |
struct B : public A { | |
void a() { cout << "OVERLOAD" << 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
================================== | |
CODE: | |
================================== | |
static int heavy(unsigned int a) { | |
int accum = 0; | |
for(unsigned int i = 0; i < a + 10; i++) | |
accum += i * i + i * 4 - i / 2; | |
return accum; | |
} |
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 <string> | |
#include <cstring> | |
using namespace std; | |
int main() { | |
string a("\0A"); | |
string b("\0B", 2); | |
cout << a.length() << endl; // 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 <iostream> | |
using namespace std; | |
int main() { | |
const char* a = "0123456789"; | |
const char b[] = "0123456789"; | |
cout << sizeof(a) << endl << sizeof(b) << endl; | |
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> | |
void f(double& var) { | |
var = 0.12; | |
} | |
int main(int argc, char** argv) { | |
float my; | |
f(my); | |
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 <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 |
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) { |
OlderNewer