This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() { | |
// _1 type _2 * _3 | |
// when const is in location _1 or_2, it means the type is const-qualified | |
// when const is in location _3, it means the ptr is const-qualified | |
// const_cast can modify the const-qualification of variable | |
// don't use const_cast unless you have to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Jingzhe Hu on 6/12/2018 Tuesday. | |
// | |
#include <string> | |
#include <algorithm> | |
#include <vector> | |
#include <iostream> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct Foo { | |
void display_greetings() { cout << "Class Foo - greetings !" << endl; } | |
void display_number(int i) { cout << "Class Foo - the integer is: " << i << endl; } | |
int data = 7; | |
static const int static_data = 90; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<typename T> | |
struct inequality { | |
bool operator!=(const T& that) { | |
return !(static_cast<const T&>(*this) == that); | |
} | |
}; | |
// mutual dependence of inequality and point |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add to the beginning of CMakeLists.txt | |
# JH edit | |
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl") | |
set(OPENSSL_LIBRARIES "/usr/local/opt/openssl/lib") | |
set(BINARYEN_ROOT "/usr/local/binaryen/") | |
set(BINARYEN_BIN "/usr/local/binaryen/bin/") | |
set(WASM_LLVM_CONFIG "/usr/local/wasm/bin/llvm-config") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func Sqrt(x float64) (float64, error) { | |
if x < 0 { | |
return 0, &ErrNegativeSqrt{x} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type IPAddr [4]byte | |
// TODO: Add a "String() string" method to IPAddr. | |
func (ip IPAddr) String() string { | |
return fmt.Sprintf("%v.%v.%v.%v", ip[0], ip[1], ip[2], ip[3]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// fibonacci is a function that returns | |
// a function that returns an int. | |
func fibonacci() func() int { | |
a := 1 | |
b := 1 | |
c := 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
z := float64(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "golang.org/x/tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
pic := make([][]uint8, dy) | |
for x := range pic { | |
pic[x] = make([]uint8, dx) | |
for y := range pic[x] { |