Programming

From stacky wiki

todo

  • make biginteger class
  • write blackbox game


hand-rolling a library

References: http://www.learncpp.com/cpp-tutorial/19-header-files/ and http://www.linuxquestions.org/questions/programming-9/how-to-compile-a-tiny-simple-library-by-g-105795/

Tested this procedure with three files:

// add.h
int add(int,int);
// foo.cpp
#include "add.h"

int add(int x, int y)
{
    return x + y;
}
// main.cpp
#include <iostream>
#include "add.h"
 
int main()
{
    using namespace std;
    cout << "The sum of 3 and 4 is: " << add(3, 4) << endl;
    return 0;
}

It's important that add.h is included using quotes instead of angle brackets; angle brackets are reserved for header files included with the compiler.

Used the following commands to produce a working executable:

g++ -c foo.cpp 
g++ main.cpp -L. foo.o