C 鮮為人知的符號

2021-10-08 08:08:37 字數 2069 閱讀 2787

目錄 1

1. 引言 1

2. 少為人知的符號表1 1

2.1. 符號表 1

2.2. **示例 2

3. 少為人知的符號表2 2

3.1. 符號表 2

3.2. **示例 3

這些鮮為人知的c++符號,可直接在**中使用,但實踐中不推薦這麼做,可作為茶餘飯後的樂趣了解c++的另一面。

雖然它們鮮為人知,但卻不是gnu

g++獨有的,而是c++標準定義的,找一本c++標準書或pdf文件看看,就可以見到它們赫然在目。(注:c++17標準已不支援這些鮮為人知的符號)

**中,可用左邊的替代右邊的:

可選的符號可替代的常見符號

<%

注意不能替代函式定義的}

<:

[:>]%:

#%:%:

##and

&&or

||xor

^bitor

|compl

~bitand

&and_eq

&=or_eq

|=xor_eq

^=not

!not_eq

!=

// gnu g++編譯方法:g++ -g -o a a.cpp

#include

intmain()

三個字元等同單個字元,gnu

g++編譯時需要指定編譯引數「-trigraphs」。注意,這個特性從c++2017標準開始已不支援。

可選的符號可替代的常見符號

??=#

??/\

??』^

??([

??)]

??<

??!|

??-~

// 注意使用gnu g++編譯以下**,需要指定編譯引數「-trigraphs」

// g++ -g -o b b.cpp -trigraphs

#include??

=define index

(array, i) array?

?(i??)

intmain()

;printf

("m[0]=%d, m[1]=%d\n"

,index

(m,0),

index

(m,1))

;return0;

}

asm

doif

return

typedef

auto

double

inline

short

typeid

bool

dynamic_cast

intsigned

typename

break

else

long

sizeof

union

case

enum

mutable

static

unsigned

catch

explicit

namespace

static_cast

using

char

export

newstruct

virtual

class

extern

operator

switch

void

const

false

private

template

volatile

const_cast

float

protected

this

wchar_t

continue

forpublic

throw

while

default

friend

register

true

鮮為人知的C 特性

翻譯至 小括號的寫法 以下寫法等價 ptr 3 ptr 3 3 ptr 3 ptr most vexing parse 這個問題,可以通過加小括號規避 運算子 字母和符號 the tokens and,and eq,bitand,bitor,compl,not,not eq,or,or eq,xor...

鮮為人知的 Python 語法

所有人 好吧,不是所有人 都知道 python 是一門用途廣泛 易讀 而且容易入門的程式語言。但同時 python 語法也允許我們做一些很奇怪的事情。眾所周知 python 的 lambda 表示式不支援多行 但是可以模擬出多行 的效果。def f x string if x.endswith g ...

parseInt鮮為人知的用法

var float num 3.14 float num parseint float num console.log float num var str num 3.14string str num parseint str num console.log str num 注意 parseint轉...