Skip to content

Instantly share code, notes, and snippets.

View onqtam's full-sized avatar
:shipit:

Viktor Kirilov onqtam

:shipit:
View GitHub Profile
#include <vector>
#include <iostream>
using namespace std;
int main() {
{
size_t cap = 0;
vector<int> v;
for(int i = 0; i < 20; i++) {
#include <iostream>
using namespace std;
struct A {
A() : data(0) {}
virtual void doStuff() {
data++;
cout << "A" << endl;
}
#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; }
==================================
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;
}
#include <string>
#include <cstring>
using namespace std;
int main() {
string a("\0A");
string b("\0B", 2);
cout << a.length() << endl; // 0
#include <iostream>
using namespace std;
int main() {
const char* a = "0123456789";
const char b[] = "0123456789";
cout << sizeof(a) << endl << sizeof(b) << endl;
return 0;
#include <cstdio>
void f(double& var) {
var = 0.12;
}
int main(int argc, char** argv) {
float my;
f(my);
return 0;
#include <iostream>
// OUTPUT IS:
// 500059
// 500058
// 2891316
struct A {
void f() {
int a; // to take the stack address
#include <iostream>
// OUTPUT IS:
// 500059
// 500058
// 2891316
struct A {
void f() {
int a; // to take the stack address
@onqtam
onqtam / rtti.cpp
Last active August 29, 2015 14:01
#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) {