finished product
This commit is contained in:
parent
db5f9714a5
commit
815175e35e
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
||||
CXX=g++
|
||||
# CPPFLAGS=-Wall -g
|
||||
# CPPFLAGS=-Wall -g -std=c++0x
|
||||
# CPPFLAGS=-Wall -g -std=c++0x -pthread
|
||||
CPPFLAGS=-Wall -g -std=c++0x -pthread
|
||||
|
||||
all:
|
||||
@echo "build things individually (make loops, etc.)"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int some_constant_func() {
|
||||
constexpr int some_constant_func() {
|
||||
return 41;
|
||||
}
|
||||
|
||||
|
1
init.cc
1
init.cc
@ -11,6 +11,7 @@ struct Point {
|
||||
|
||||
int main() {
|
||||
string s1("first");
|
||||
string s3 = string("again");
|
||||
int x = int(42);
|
||||
string s2 = "hello";
|
||||
int y = 42;
|
||||
|
@ -13,9 +13,9 @@ 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},
|
||||
map<string, vector<int>> singers = {
|
||||
{"Freddie Mercury", {100, 102, 103}},
|
||||
{"Matt Bellamy", {100, 104, 105}},
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
11
tuple.cc
11
tuple.cc
@ -3,16 +3,21 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
// make a function that returns multiple values
|
||||
auto some_func() -> tuple<int, int> {
|
||||
return make_tuple(4, 2);
|
||||
}
|
||||
|
||||
int main() {
|
||||
tuple<int, int> c = make_tuple(5, 4);
|
||||
auto c = make_tuple(5, 4);
|
||||
cout << get<0>(c) << endl;
|
||||
|
||||
int a = 0;
|
||||
int b = 1;
|
||||
tie(a, b) = make_tuple(b, a);
|
||||
cout << a << endl;
|
||||
cout << b << endl;
|
||||
// swap a, b
|
||||
// get a,b from func ...
|
||||
tie(a, b) = some_func();
|
||||
cout << a << endl;
|
||||
cout << b << endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user