Skip to content

Instantly share code, notes, and snippets.

// This program demonstrates a destructor.
#include <iostream>
#include <string>
using namespace std;
// Class specification
class Demo {
public:
Demo(); // Constructor
@raarce
raarce / destructor01.cpp
Created August 17, 2012 20:17
Destructor Demo
// This program demonstrates a destructor.
#include <iostream>
#include <string>
using namespace std;
// Class specification
class Demo {
public:
Demo(); // Constructor
@raarce
raarce / arrayOfObjects.cpp
Created August 17, 2012 20:38
Demo of array of objects
// Program to demo an array of class objects
// Adapted from http://codeprecisely.blogspot.com/2011/09/program-to-demonstrates-array-of.html
#include <iostream>
#include <string>
using namespace std;
class Book {
private:
void MainWindow::foo() {
qDebug() << "clicked the button";
}
@raarce
raarce / overload01.cpp
Created August 20, 2012 03:05
Demo overload 01
// This program demonstrates how to overload
// the post-increment operator
// https://gist.github.com/3399944
#include <iostream>
#include <string>
using namespace std;
class Fraction {
@raarce
raarce / conditional.cpp
Created August 21, 2012 00:56
Conditional Assignment
// Ejemplo cout usando conditional assignment
#include <iostream>
using namespace std;
int main (void) {
int a = 35;
cout << "El numero es " << ((a % 2) ? "impar." : "par.") << endl;
@raarce
raarce / CLA01.cpp
Created August 21, 2012 00:58
Command line argument example 01
// Command line argument example #01
#include <iostream>
using namespace std;
int main ( int argc, char *argv[] )
{
if ( argc < 2 ) {
cout<<"usage: "<< argv[0] <<" <your name>\n";
exit(1);
@raarce
raarce / CLA02.cpp
Created August 21, 2012 00:59
Command line argument example 02
// Command line argument example #02
#include <iostream>
using namespace std;
bool isNum(char *st) {
int i = 0;
while (st[i] != '\0') {
if (st[i] < '0' || st[i] > '9') return false;
i++;
@raarce
raarce / CLA03.cpp
Created August 21, 2012 01:00
Command line argument example 03
// Command line argument example #03
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;
int main ( int argc, char *argv[] )
@raarce
raarce / gist:3410161
Created August 21, 2012 01:03
Ejemplo para practicar uso de Makefile
// OJO: Este archivo contiene código que debe ser separado
// en los archivos: Rectangle.cpp, Rectangle.h, RectangleClient.cpp,
// y Makefile
//------ Rectangle.h file begins ---------------------
#include <iostream>
using namespace std;