Skip to content

Instantly share code, notes, and snippets.

int length = 100; //value of length can be determined at run-time
int *dyn = new int[length]; //new int[length] returns a pointer to
//first element of the array.
cout << "Using pointers:" << endl;
*dyn = 10; //dyn[0] and *dyn are equivalent!
*(dyn + 1) = 15; // *(dyn + 1) and dyn[1] are equivalent!
@svenoaks
svenoaks / gist:8514257
Created January 20, 2014 03:06
Passing an object with pointers by value
#include <iostream>
#include <string>
using namespace std;
class passed
{
char *str;
#define _USE_MATH_DEFINES
#define L_TO_CU_FT 28.32
#include <iostream>
#include <math.h>
#include <sstream>
using namespace std;
void getDimensions(double&, double&);
#include <iostream>
using namespace std;
template <class E>
class LinkedList
{
struct Node;
Node* first;
@svenoaks
svenoaks / gist:9148060
Last active August 29, 2015 13:56
A very primitive Java web server
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.CharBuffer;
@svenoaks
svenoaks / gist:9432055
Created March 8, 2014 15:14
JavaScript invoking "super" functions
// define the Person Class
function Person(name) {
this.name = name;
this.hasSaidHello = false;
}
Person.prototype.walk = function(){
alert ('I am walking!');
};
Person.prototype.sayHello = function(){
package com.smp.soundtouchandroid;
import android.os.AsyncTask;
import android.util.Log;
import com.smp.soundtouchandroid.*;
import java.io.FileOutputStream;
import java.io.IOException;
public class SoundTouchRecorder
//
// main.cpp
// intui
//
// Created by Steve Myers on 6/28/14.
// Copyright (c) 2014 ___SMP_PRODUCTIONS___. All rights reserved.
//
#include <iostream>
#include <list>
Module Module1
Dim GlobalWord As String
Class PersonType
Public Sub New()
SecretName = "hushhush"
End Sub
Public Property FirstName As String
/* Javascript to emulate media queries with events and HTML class toggling
* to avoid duplication, conflict & waste when implemented via
* native CSS implementation + JS feature dependency.
*
* Depends on jQuery and Cowboy's throttle / debounce plugin:
* https://github.com/cowboy/jquery-throttle-debounce
*/
(function(){
var options = {