added a bunch of exmaples and some notes

This commit is contained in:
Stephen M. McQuay 2012-05-05 09:01:40 -06:00
parent 4595d554dc
commit 71adea8733
7 changed files with 72 additions and 39 deletions

9
Makefile Normal file
View File

@ -0,0 +1,9 @@
CXX=g++
CPPFLAGS=-Wall -g -std=c++0x
# CPPFLAGS=-Wall -g
all:
@echo "build things individually (make loops, etc.)"
clean:
@rm -vf auto constexpr ilists2 ilists init init_new loops

17
ilists.cc Normal file
View File

@ -0,0 +1,17 @@
#include <vector>
// valid c++03:
struct thang
{
float f;
int i;
};
thang scalar = {3.14, 42};
thang anArray[] = {{1.1, 1}, {2.2, 2}, {3.3, 3}};
int main() {
// vector<thang> v = { ??? }
return 0;
}

7
ilists2.cc Normal file
View File

@ -0,0 +1,7 @@
void function_name(std::initializer_list<float> list);
function_name({1.0f, -3.45f, -0.4f});
int main() {
return 0;
}

18
init.cc Normal file
View File

@ -0,0 +1,18 @@
#include <string>
using namespace std;
struct Point {
int x, y;
Point(int x, int y): x(x), y(y){}
};
// const vector<string> v = ??;
// http://stackoverflow.com/a/4268956
int main() {
string s1("first");
int x = int(42);
string s2 = "hello";
int y = 42;
return 0;
}

21
init_new.cc Normal file
View File

@ -0,0 +1,21 @@
#include <string>
#include <vector>
#include <map>
using namespace std;
struct Point {
int x, y;
Point(int x, int y): x{x}, y{y}{}
};
const vector<string> s = {"a", "b", "c"};
int main() {
string s1 {"first"};
int x {42};
map<string, int> singers = {
{"Freddie Mercury", 100},
{"Matt Bellamy", 100},
};
return 0;
}

View File

@ -1,26 +0,0 @@
CXX=clang++
CPPFLAGS=-Wall -g -std=c++0x
SOURCES=main.cc
OBJECTS=$(SOURCES:.cc=.o)
EXE=app
all: $(EXE)
main.o: main.cc
$(EXE): $(OBJECTS)
$(CXX) $(LDFLAGS) $(OBJECTS) -o $@
run: $(EXE)
./$(EXE)
clean:
@rm -vf *.o
@rm -rvf *.dSYM
@rm -vf $(EXE)
debug: $(EXE)
gdb $(EXE)
valgrind: $(EXE)
valgrind --tool=memcheck --leak-check=yes ./$(EXE)

View File

@ -1,13 +0,0 @@
#include <iostream>
using namespace std;
const string usage = "usage: regex";
int main(int argc, char * argv []) {
if(argc != 1) {
cerr << usage << endl;
return 1;
}
cout << "hello cruel world" << endl;
return 0;
}