-
object (its delegate).
class Rectangle(
val width:
Int,
val height:
Int) { fun area() =
width *
height }
class Window(
val bounds: Rectangle) { // Delegation...
- reached:
int find(
int arr[],
size_t len,
int val) {
int last; if (len == 0)
return -1; last = arr[len - 1]; arr[len - 1] =
val; // add
sentinel value int i;...
- sig type t
val zero : t
val succ : t -> t
val sum : t * t -> t end
structure Rational :
ARITH =
struct datatype t = Rat of
int *
int val zero = Rat (0...
- own type is
commonly used to
build linked data structures:
struct node {
int val;
struct node *next; }; For
every type T,
except void and
function types...
- print_number(
int (*get_number)(void)) {
int val = get_number(); printf("Value: %d\n",
val); }
int get_answer_to_most_important_question(void) {
return 42; }
int main(void)...
- C:
struct node {
int val;
struct node *next; }; This is an
example using typedefs:
typedef struct node node;
struct node {
int val; node *next; }; Note:...
- Print(const std::vector<
int>& vec) { for (auto
val : vec) { std::cout <<
val << ' '; } std::cout << '\n'; }
int main() { std::vector<
int> v = {0, 1, 2, 3, 4...
- header):
int val = 20; /* 8
octets of
header + 12
octets of the
application protocol. */ (void)setsockopt(fd, SOL_UDPLITE, UDPLITE_SEND_CSCOV, &
val, sizeof...
-
int num = -1;
unsigned int val = 1 << num; //
shifting by a
negative number -
undefined behavior num = 32; // or
whatever number greater than 31
val =...
- files. ++n;
int num; if (n == 0) num = 0; else { num = 1; for (
int i = 0; i < n-1; ++i) {
int val = 1; for (
int j = 0; j < num; ++j)
val = (
val << 1) | bitreader...