[{"data":1,"prerenderedAt":5610},["ShallowReactive",2],{"wiki-page-\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian":3,"wiki-doc-items-\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian":5190,"language-switcher-data-\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian":5594,"wiki-i18n-paths-\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian":5609},{"id":4,"title":5,"body":6,"canonicalPath":5171,"chapterDepth":5172,"chapterOrder":5173,"date":5174,"description":66,"docI18nKey":5175,"docKey":5176,"docRoot":5177,"docTitle":5178,"extension":5179,"i18nKey":5180,"isBlogPost":5181,"isWikiDoc":90,"isWikiIndex":5181,"layout":5182,"legacyPath":5182,"locale":5183,"localeSlug":5184,"meta":5185,"navigation":90,"path":5171,"seo":5186,"sourcePath":5187,"sourceStem":5180,"stem":5188,"wikiDepth":74,"__hash__":5189},"content\u002F_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0800-函数与头文件.md","Functions and Header Files",{"type":7,"value":8,"toc":5154},"minimark",[9,13,18,26,29,33,36,55,60,120,130,148,154,231,237,241,247,255,259,506,510,518,524,528,536,540,832,836,842,847,851,854,868,872,1114,1120,1124,1129,1142,1146,1337,1341,1347,1351,1356,1363,1366,1388,1397,1403,1430,1433,1439,1442,1483,1488,1494,1501,1527,1532,1536,1539,1545,1548,1598,1603,1615,1631,1635,1637,1643,1645,1753,1758,1768,1779,1783,1785,1791,1793,1870,1878,1884,1889,1897,1901,1903,1909,1918,1921,1943,1946,1964,1967,1973,1976,1983,2027,2030,2037,2308,2311,2338,2351,2354,2393,2400,2411,2428,2446,2450,2452,2458,2461,2481,2483,2495,2507,2532,2535,2538,2569,2571,2597,2600,2605,2744,2747,2757,2766,2790,2803,2807,2810,2815,2818,2823,2826,2831,2834,2839,2845,2849,2852,2855,2936,2944,2953,2956,2980,2985,2989,3001,3004,3018,3028,3032,3044,3047,3110,3113,3131,3137,3211,3214,3217,3222,3237,3247,3257,3267,3271,3293,3296,3302,3307,3416,3422,3431,3440,3447,3450,3456,3461,3472,3478,3569,3577,3586,3701,3706,3779,3785,3790,3795,3819,3826,3831,3837,3845,3852,3857,3859,3865,3871,3894,3896,3920,3925,4015,4023,4145,4156,4169,4246,4258,4264,4287,4292,4300,4304,4313,4319,4340,4342,4348,4357,4443,4453,4458,4503,4517,4525,4592,4604,4609,4632,4647,4650,4700,4705,4838,4844,4937,4953,4962,4992,5006,5013,5024,5037,5050,5066,5069,5074,5091,5100,5103,5121,5124,5134,5144,5150],[10,11,12],"h2",{"id":12},"function",[14,15,17],"h3",{"id":16},"overview","Overview",[19,20,21,25],"p",{},[22,23,24],"strong",{},"Purpose:"," Encapsulate a segment of frequently used code to reduce repetitive code.",[19,27,28],{},"A large program is generally divided into several modules, each of which implements specific functions.",[14,30,32],{"id":31},"function-definition","function definition",[19,34,35],{},"A function definition typically involves 5 main steps:",[37,38,39,43,46,49,52],"ol",{},[40,41,42],"li",{},"Return value type",[40,44,45],{},"Function Name",[40,47,48],{},"Parameter Table",[40,50,51],{},"Function body statements",[40,53,54],{},"return expression",[19,56,57],{},[22,58,59],{},"Syntax:",[61,62,67],"pre",{"className":63,"code":64,"language":65,"meta":66,"style":66},"language-cpp shiki shiki-themes github-light github-dark","返回值类型 函数名 （参数列表）\n{\n\n       函数体语句\n\n       return表达式\n\n}\n","cpp","",[68,69,70,79,85,92,98,103,109,114],"code",{"__ignoreMap":66},[71,72,75],"span",{"class":73,"line":74},"line",1,[71,76,78],{"class":77},"sVt8B","返回值类型 函数名 （参数列表）\n",[71,80,82],{"class":73,"line":81},2,[71,83,84],{"class":77},"{\n",[71,86,88],{"class":73,"line":87},3,[71,89,91],{"emptyLinePlaceholder":90},true,"\n",[71,93,95],{"class":73,"line":94},4,[71,96,97],{"class":77},"       函数体语句\n",[71,99,101],{"class":73,"line":100},5,[71,102,91],{"emptyLinePlaceholder":90},[71,104,106],{"class":73,"line":105},6,[71,107,108],{"class":77},"       return表达式\n",[71,110,112],{"class":73,"line":111},7,[71,113,91],{"emptyLinePlaceholder":90},[71,115,117],{"class":73,"line":116},8,[71,118,119],{"class":77},"}\n",[19,121,122,125,126,129],{},[22,123,124],{},"运行结果："," 此代码块不含 ",[68,127,128],{},"main"," 函数，是语法、接口或分文件示例，不能独立运行，因此没有终端输出。",[131,132,133,136,139,142,145],"ul",{},[40,134,135],{},"Return type: A function can return a value. In the function definition",[40,137,138],{},"Function name: give the function a name",[40,140,141],{},"Parameter list: the data passed in when using this function",[40,143,144],{},"Function body statements: The code inside curly braces, which are the statements that need to be executed within the function.",[40,146,147],{},"Return expressions are tied to the return type, and after a function completes execution, it returns the corresponding data.",[19,149,150,153],{},[22,151,152],{},"Example:"," Define an addition function to add two numbers.",[61,155,157],{"className":63,"code":156,"language":65,"meta":66,"style":66},"\u002F\u002F函数定义\nint add(int num1, int num2)\n{\n    int sum = num1 + num2;\n    return sum;\n}\n",[68,158,159,165,195,199,219,227],{"__ignoreMap":66},[71,160,161],{"class":73,"line":74},[71,162,164],{"class":163},"sJ8bj","\u002F\u002F函数定义\n",[71,166,167,171,175,178,180,184,187,189,192],{"class":73,"line":81},[71,168,170],{"class":169},"szBVR","int",[71,172,174],{"class":173},"sScJk"," add",[71,176,177],{"class":77},"(",[71,179,170],{"class":169},[71,181,183],{"class":182},"s4XuR"," num1",[71,185,186],{"class":77},", ",[71,188,170],{"class":169},[71,190,191],{"class":182}," num2",[71,193,194],{"class":77},")\n",[71,196,197],{"class":73,"line":87},[71,198,84],{"class":77},[71,200,201,204,207,210,213,216],{"class":73,"line":94},[71,202,203],{"class":169},"    int",[71,205,206],{"class":77}," sum ",[71,208,209],{"class":169},"=",[71,211,212],{"class":77}," num1 ",[71,214,215],{"class":169},"+",[71,217,218],{"class":77}," num2;\n",[71,220,221,224],{"class":73,"line":100},[71,222,223],{"class":169},"    return",[71,225,226],{"class":77}," sum;\n",[71,228,229],{"class":73,"line":105},[71,230,119],{"class":77},[19,232,233,125,235,129],{},[22,234,124],{},[68,236,128],{},[14,238,240],{"id":239},"function-call","Function call",[19,242,243,246],{},[22,244,245],{},"Function:"," Use predefined functions",[19,248,249,251,252],{},[22,250,59],{}," ",[68,253,254],{}," 函数名（参数）",[19,256,257],{},[22,258,152],{},[61,260,262],{"className":63,"code":261,"language":65,"meta":66,"style":66},"\u002F\u002F函数定义\nint add(int num1, int num2) \u002F\u002F定义中的num1,num2称为形式参数，简称形参\n{\n    int sum = num1 + num2;\n    return sum;\n}\n\nint main() {\n\n    int a = 10;\n    int b = 10;\n    \u002F\u002F调用add函数\n    int sum = add(a, b);\u002F\u002F调用时的a，b称为实际参数，简称实参\n    cout \u003C\u003C \"sum = \" \u003C\u003C sum \u003C\u003C endl;\n\n    a = 100;\n    b = 100;\n\n    sum = add(a, b);\n    cout \u003C\u003C \"sum = \" \u003C\u003C sum \u003C\u003C endl;\n\n\n    return 0;\n}\n",[68,263,264,268,292,296,310,316,320,324,334,339,356,370,376,393,416,421,434,446,451,464,481,486,491,501],{"__ignoreMap":66},[71,265,266],{"class":73,"line":74},[71,267,164],{"class":163},[71,269,270,272,274,276,278,280,282,284,286,289],{"class":73,"line":81},[71,271,170],{"class":169},[71,273,174],{"class":173},[71,275,177],{"class":77},[71,277,170],{"class":169},[71,279,183],{"class":182},[71,281,186],{"class":77},[71,283,170],{"class":169},[71,285,191],{"class":182},[71,287,288],{"class":77},")",[71,290,291],{"class":163}," \u002F\u002F定义中的num1,num2称为形式参数，简称形参\n",[71,293,294],{"class":73,"line":87},[71,295,84],{"class":77},[71,297,298,300,302,304,306,308],{"class":73,"line":94},[71,299,203],{"class":169},[71,301,206],{"class":77},[71,303,209],{"class":169},[71,305,212],{"class":77},[71,307,215],{"class":169},[71,309,218],{"class":77},[71,311,312,314],{"class":73,"line":100},[71,313,223],{"class":169},[71,315,226],{"class":77},[71,317,318],{"class":73,"line":105},[71,319,119],{"class":77},[71,321,322],{"class":73,"line":111},[71,323,91],{"emptyLinePlaceholder":90},[71,325,326,328,331],{"class":73,"line":116},[71,327,170],{"class":169},[71,329,330],{"class":173}," main",[71,332,333],{"class":77},"() {\n",[71,335,337],{"class":73,"line":336},9,[71,338,91],{"emptyLinePlaceholder":90},[71,340,342,344,347,349,353],{"class":73,"line":341},10,[71,343,203],{"class":169},[71,345,346],{"class":77}," a ",[71,348,209],{"class":169},[71,350,352],{"class":351},"sj4cs"," 10",[71,354,355],{"class":77},";\n",[71,357,359,361,364,366,368],{"class":73,"line":358},11,[71,360,203],{"class":169},[71,362,363],{"class":77}," b ",[71,365,209],{"class":169},[71,367,352],{"class":351},[71,369,355],{"class":77},[71,371,373],{"class":73,"line":372},12,[71,374,375],{"class":163},"    \u002F\u002F调用add函数\n",[71,377,379,381,383,385,387,390],{"class":73,"line":378},13,[71,380,203],{"class":169},[71,382,206],{"class":77},[71,384,209],{"class":169},[71,386,174],{"class":173},[71,388,389],{"class":77},"(a, b);",[71,391,392],{"class":163},"\u002F\u002F调用时的a，b称为实际参数，简称实参\n",[71,394,396,399,402,406,409,411,413],{"class":73,"line":395},14,[71,397,398],{"class":77},"    cout ",[71,400,401],{"class":169},"\u003C\u003C",[71,403,405],{"class":404},"sZZnC"," \"sum = \"",[71,407,408],{"class":169}," \u003C\u003C",[71,410,206],{"class":77},[71,412,401],{"class":169},[71,414,415],{"class":77}," endl;\n",[71,417,419],{"class":73,"line":418},15,[71,420,91],{"emptyLinePlaceholder":90},[71,422,424,427,429,432],{"class":73,"line":423},16,[71,425,426],{"class":77},"    a ",[71,428,209],{"class":169},[71,430,431],{"class":351}," 100",[71,433,355],{"class":77},[71,435,437,440,442,444],{"class":73,"line":436},17,[71,438,439],{"class":77},"    b ",[71,441,209],{"class":169},[71,443,431],{"class":351},[71,445,355],{"class":77},[71,447,449],{"class":73,"line":448},18,[71,450,91],{"emptyLinePlaceholder":90},[71,452,454,457,459,461],{"class":73,"line":453},19,[71,455,456],{"class":77},"    sum ",[71,458,209],{"class":169},[71,460,174],{"class":173},[71,462,463],{"class":77},"(a, b);\n",[71,465,467,469,471,473,475,477,479],{"class":73,"line":466},20,[71,468,398],{"class":77},[71,470,401],{"class":169},[71,472,405],{"class":404},[71,474,408],{"class":169},[71,476,206],{"class":77},[71,478,401],{"class":169},[71,480,415],{"class":77},[71,482,484],{"class":73,"line":483},21,[71,485,91],{"emptyLinePlaceholder":90},[71,487,489],{"class":73,"line":488},22,[71,490,91],{"emptyLinePlaceholder":90},[71,492,494,496,499],{"class":73,"line":493},23,[71,495,223],{"class":169},[71,497,498],{"class":351}," 0",[71,500,355],{"class":77},[71,502,504],{"class":73,"line":503},24,[71,505,119],{"class":77},[19,507,508],{},[22,509,124],{},[61,511,516],{"className":512,"code":514,"language":515,"meta":66},[513],"language-text","sum = 20\nsum = 200\n","text",[68,517,514],{"__ignoreMap":66},[519,520,521],"blockquote",{},[19,522,523],{},"Summary: In a function definition, parameters within parentheses are called formal parameters, while parameters passed during function invocation are called actual parameters.",[14,525,527],{"id":526},"pass-by-value","Pass-by-value",[131,529,530,533],{},[40,531,532],{},"Pass-by-value means that when a function is called, the actual parameters pass their values to the formal parameters.",[40,534,535],{},"When passing by value, ==if the parameter changes, it does not affect the argument==.",[19,537,538],{},[22,539,152],{},[61,541,543],{"className":63,"code":542,"language":65,"meta":66,"style":66},"void swap(int num1, int num2)\n{\n    cout \u003C\u003C \"交换前：\" \u003C\u003C endl;\n    cout \u003C\u003C \"num1 = \" \u003C\u003C num1 \u003C\u003C endl;\n    cout \u003C\u003C \"num2 = \" \u003C\u003C num2 \u003C\u003C endl;\n\n    int temp = num1;\n    num1 = num2;\n    num2 = temp;\n\n    cout \u003C\u003C \"交换后：\" \u003C\u003C endl;\n    cout \u003C\u003C \"num1 = \" \u003C\u003C num1 \u003C\u003C endl;\n    cout \u003C\u003C \"num2 = \" \u003C\u003C num2 \u003C\u003C endl;\n\n    \u002F\u002Freturn ; 当函数声明时候，不需要返回值，可以不写return\n}\n\nint main() {\n\n    int a = 10;\n    int b = 20;\n\n    swap(a, b);\n\n    cout \u003C\u003C \"mian中的 a = \" \u003C\u003C a \u003C\u003C endl;\n    cout \u003C\u003C \"mian中的 b = \" \u003C\u003C b \u003C\u003C endl;\n\n\n    return 0;\n}\n",[68,544,545,567,571,584,601,619,623,635,644,654,658,671,687,703,707,712,716,720,728,732,744,757,761,768,772,790,808,813,818,827],{"__ignoreMap":66},[71,546,547,550,553,555,557,559,561,563,565],{"class":73,"line":74},[71,548,549],{"class":169},"void",[71,551,552],{"class":173}," swap",[71,554,177],{"class":77},[71,556,170],{"class":169},[71,558,183],{"class":182},[71,560,186],{"class":77},[71,562,170],{"class":169},[71,564,191],{"class":182},[71,566,194],{"class":77},[71,568,569],{"class":73,"line":81},[71,570,84],{"class":77},[71,572,573,575,577,580,582],{"class":73,"line":87},[71,574,398],{"class":77},[71,576,401],{"class":169},[71,578,579],{"class":404}," \"交换前：\"",[71,581,408],{"class":169},[71,583,415],{"class":77},[71,585,586,588,590,593,595,597,599],{"class":73,"line":94},[71,587,398],{"class":77},[71,589,401],{"class":169},[71,591,592],{"class":404}," \"num1 = \"",[71,594,408],{"class":169},[71,596,212],{"class":77},[71,598,401],{"class":169},[71,600,415],{"class":77},[71,602,603,605,607,610,612,615,617],{"class":73,"line":100},[71,604,398],{"class":77},[71,606,401],{"class":169},[71,608,609],{"class":404}," \"num2 = \"",[71,611,408],{"class":169},[71,613,614],{"class":77}," num2 ",[71,616,401],{"class":169},[71,618,415],{"class":77},[71,620,621],{"class":73,"line":105},[71,622,91],{"emptyLinePlaceholder":90},[71,624,625,627,630,632],{"class":73,"line":111},[71,626,203],{"class":169},[71,628,629],{"class":77}," temp ",[71,631,209],{"class":169},[71,633,634],{"class":77}," num1;\n",[71,636,637,640,642],{"class":73,"line":116},[71,638,639],{"class":77},"    num1 ",[71,641,209],{"class":169},[71,643,218],{"class":77},[71,645,646,649,651],{"class":73,"line":336},[71,647,648],{"class":77},"    num2 ",[71,650,209],{"class":169},[71,652,653],{"class":77}," temp;\n",[71,655,656],{"class":73,"line":341},[71,657,91],{"emptyLinePlaceholder":90},[71,659,660,662,664,667,669],{"class":73,"line":358},[71,661,398],{"class":77},[71,663,401],{"class":169},[71,665,666],{"class":404}," \"交换后：\"",[71,668,408],{"class":169},[71,670,415],{"class":77},[71,672,673,675,677,679,681,683,685],{"class":73,"line":372},[71,674,398],{"class":77},[71,676,401],{"class":169},[71,678,592],{"class":404},[71,680,408],{"class":169},[71,682,212],{"class":77},[71,684,401],{"class":169},[71,686,415],{"class":77},[71,688,689,691,693,695,697,699,701],{"class":73,"line":378},[71,690,398],{"class":77},[71,692,401],{"class":169},[71,694,609],{"class":404},[71,696,408],{"class":169},[71,698,614],{"class":77},[71,700,401],{"class":169},[71,702,415],{"class":77},[71,704,705],{"class":73,"line":395},[71,706,91],{"emptyLinePlaceholder":90},[71,708,709],{"class":73,"line":418},[71,710,711],{"class":163},"    \u002F\u002Freturn ; 当函数声明时候，不需要返回值，可以不写return\n",[71,713,714],{"class":73,"line":423},[71,715,119],{"class":77},[71,717,718],{"class":73,"line":436},[71,719,91],{"emptyLinePlaceholder":90},[71,721,722,724,726],{"class":73,"line":448},[71,723,170],{"class":169},[71,725,330],{"class":173},[71,727,333],{"class":77},[71,729,730],{"class":73,"line":453},[71,731,91],{"emptyLinePlaceholder":90},[71,733,734,736,738,740,742],{"class":73,"line":466},[71,735,203],{"class":169},[71,737,346],{"class":77},[71,739,209],{"class":169},[71,741,352],{"class":351},[71,743,355],{"class":77},[71,745,746,748,750,752,755],{"class":73,"line":483},[71,747,203],{"class":169},[71,749,363],{"class":77},[71,751,209],{"class":169},[71,753,754],{"class":351}," 20",[71,756,355],{"class":77},[71,758,759],{"class":73,"line":488},[71,760,91],{"emptyLinePlaceholder":90},[71,762,763,766],{"class":73,"line":493},[71,764,765],{"class":173},"    swap",[71,767,463],{"class":77},[71,769,770],{"class":73,"line":503},[71,771,91],{"emptyLinePlaceholder":90},[71,773,775,777,779,782,784,786,788],{"class":73,"line":774},25,[71,776,398],{"class":77},[71,778,401],{"class":169},[71,780,781],{"class":404}," \"mian中的 a = \"",[71,783,408],{"class":169},[71,785,346],{"class":77},[71,787,401],{"class":169},[71,789,415],{"class":77},[71,791,793,795,797,800,802,804,806],{"class":73,"line":792},26,[71,794,398],{"class":77},[71,796,401],{"class":169},[71,798,799],{"class":404}," \"mian中的 b = \"",[71,801,408],{"class":169},[71,803,363],{"class":77},[71,805,401],{"class":169},[71,807,415],{"class":77},[71,809,811],{"class":73,"line":810},27,[71,812,91],{"emptyLinePlaceholder":90},[71,814,816],{"class":73,"line":815},28,[71,817,91],{"emptyLinePlaceholder":90},[71,819,821,823,825],{"class":73,"line":820},29,[71,822,223],{"class":169},[71,824,498],{"class":351},[71,826,355],{"class":77},[71,828,830],{"class":73,"line":829},30,[71,831,119],{"class":77},[19,833,834],{},[22,835,124],{},[61,837,840],{"className":838,"code":839,"language":515,"meta":66},[513],"交换前：\nnum1 = 10\nnum2 = 20\n交换后：\nnum1 = 20\nnum2 = 10\nmian中的 a = 10\nmian中的 b = 20\n",[68,841,839],{"__ignoreMap":66},[519,843,844],{},[19,845,846],{},"Summary: When passing by value, the formal parameter cannot modify the actual argument.",[14,848,850],{"id":849},"common-styles-of-functions","Common Styles of Functions",[19,852,853],{},"There are 4 common function styles.",[37,855,856,859,862,865],{},[40,857,858],{},"no parameter no return",[40,860,861],{},"function with parameters but no return value",[40,863,864],{},"No parameters, but returns a value.",[40,866,867],{},"with parameters and return values",[19,869,870],{},[22,871,152],{},[61,873,875],{"className":63,"code":874,"language":65,"meta":66,"style":66},"\u002F\u002F函数常见样式\n\u002F\u002F1、 无参无返\nvoid test01()\n{\n    \u002F\u002Fvoid a = 10; \u002F\u002F无类型不可以创建变量,原因无法分配内存\n    cout \u003C\u003C \"this is test01\" \u003C\u003C endl;\n    \u002F\u002Ftest01(); 函数调用\n}\n\n\u002F\u002F2、 有参无返\nvoid test02(int a)\n{\n    cout \u003C\u003C \"this is test02\" \u003C\u003C endl;\n    cout \u003C\u003C \"a = \" \u003C\u003C a \u003C\u003C endl;\n}\n\n\u002F\u002F3、无参有返\nint test03()\n{\n    cout \u003C\u003C \"this is test03 \" \u003C\u003C endl;\n    return 10;\n}\n\n\u002F\u002F4、有参有返\nint test04(int a, int b)\n{\n    cout \u003C\u003C \"this is test04 \" \u003C\u003C endl;\n    int sum = a + b;\n    return sum;\n}\n",[68,876,877,882,887,897,901,909,922,927,931,935,940,956,960,973,990,994,998,1003,1012,1016,1029,1037,1041,1045,1050,1072,1076,1089,1104,1110],{"__ignoreMap":66},[71,878,879],{"class":73,"line":74},[71,880,881],{"class":163},"\u002F\u002F函数常见样式\n",[71,883,884],{"class":73,"line":81},[71,885,886],{"class":163},"\u002F\u002F1、 无参无返\n",[71,888,889,891,894],{"class":73,"line":87},[71,890,549],{"class":169},[71,892,893],{"class":173}," test01",[71,895,896],{"class":77},"()\n",[71,898,899],{"class":73,"line":94},[71,900,84],{"class":77},[71,902,903,906],{"class":73,"line":100},[71,904,905],{"class":163},"    \u002F\u002Fvoid a = 10;",[71,907,908],{"class":163}," \u002F\u002F无类型不可以创建变量,原因无法分配内存\n",[71,910,911,913,915,918,920],{"class":73,"line":105},[71,912,398],{"class":77},[71,914,401],{"class":169},[71,916,917],{"class":404}," \"this is test01\"",[71,919,408],{"class":169},[71,921,415],{"class":77},[71,923,924],{"class":73,"line":111},[71,925,926],{"class":163},"    \u002F\u002Ftest01(); 函数调用\n",[71,928,929],{"class":73,"line":116},[71,930,119],{"class":77},[71,932,933],{"class":73,"line":336},[71,934,91],{"emptyLinePlaceholder":90},[71,936,937],{"class":73,"line":341},[71,938,939],{"class":163},"\u002F\u002F2、 有参无返\n",[71,941,942,944,947,949,951,954],{"class":73,"line":358},[71,943,549],{"class":169},[71,945,946],{"class":173}," test02",[71,948,177],{"class":77},[71,950,170],{"class":169},[71,952,953],{"class":182}," a",[71,955,194],{"class":77},[71,957,958],{"class":73,"line":372},[71,959,84],{"class":77},[71,961,962,964,966,969,971],{"class":73,"line":378},[71,963,398],{"class":77},[71,965,401],{"class":169},[71,967,968],{"class":404}," \"this is test02\"",[71,970,408],{"class":169},[71,972,415],{"class":77},[71,974,975,977,979,982,984,986,988],{"class":73,"line":395},[71,976,398],{"class":77},[71,978,401],{"class":169},[71,980,981],{"class":404}," \"a = \"",[71,983,408],{"class":169},[71,985,346],{"class":77},[71,987,401],{"class":169},[71,989,415],{"class":77},[71,991,992],{"class":73,"line":418},[71,993,119],{"class":77},[71,995,996],{"class":73,"line":423},[71,997,91],{"emptyLinePlaceholder":90},[71,999,1000],{"class":73,"line":436},[71,1001,1002],{"class":163},"\u002F\u002F3、无参有返\n",[71,1004,1005,1007,1010],{"class":73,"line":448},[71,1006,170],{"class":169},[71,1008,1009],{"class":173}," test03",[71,1011,896],{"class":77},[71,1013,1014],{"class":73,"line":453},[71,1015,84],{"class":77},[71,1017,1018,1020,1022,1025,1027],{"class":73,"line":466},[71,1019,398],{"class":77},[71,1021,401],{"class":169},[71,1023,1024],{"class":404}," \"this is test03 \"",[71,1026,408],{"class":169},[71,1028,415],{"class":77},[71,1030,1031,1033,1035],{"class":73,"line":483},[71,1032,223],{"class":169},[71,1034,352],{"class":351},[71,1036,355],{"class":77},[71,1038,1039],{"class":73,"line":488},[71,1040,119],{"class":77},[71,1042,1043],{"class":73,"line":493},[71,1044,91],{"emptyLinePlaceholder":90},[71,1046,1047],{"class":73,"line":503},[71,1048,1049],{"class":163},"\u002F\u002F4、有参有返\n",[71,1051,1052,1054,1057,1059,1061,1063,1065,1067,1070],{"class":73,"line":774},[71,1053,170],{"class":169},[71,1055,1056],{"class":173}," test04",[71,1058,177],{"class":77},[71,1060,170],{"class":169},[71,1062,953],{"class":182},[71,1064,186],{"class":77},[71,1066,170],{"class":169},[71,1068,1069],{"class":182}," b",[71,1071,194],{"class":77},[71,1073,1074],{"class":73,"line":792},[71,1075,84],{"class":77},[71,1077,1078,1080,1082,1085,1087],{"class":73,"line":810},[71,1079,398],{"class":77},[71,1081,401],{"class":169},[71,1083,1084],{"class":404}," \"this is test04 \"",[71,1086,408],{"class":169},[71,1088,415],{"class":77},[71,1090,1091,1093,1095,1097,1099,1101],{"class":73,"line":815},[71,1092,203],{"class":169},[71,1094,206],{"class":77},[71,1096,209],{"class":169},[71,1098,346],{"class":77},[71,1100,215],{"class":169},[71,1102,1103],{"class":77}," b;\n",[71,1105,1106,1108],{"class":73,"line":820},[71,1107,223],{"class":169},[71,1109,226],{"class":77},[71,1111,1112],{"class":73,"line":829},[71,1113,119],{"class":77},[19,1115,1116,125,1118,129],{},[22,1117,124],{},[68,1119,128],{},[14,1121,1123],{"id":1122},"function-declaration","Function Declaration",[19,1125,1126,1128],{},[22,1127,24],{}," Specifies to the compiler the function name and how the function is to be called. The actual implementation of the function can be defined separately.",[131,1130,1131],{},[40,1132,1133,1134,1137,1138,1141],{},"Function ",[22,1135,1136],{},"declarations can be made multiple times",", but a function ",[22,1139,1140],{},"can only have one definition",".",[19,1143,1144],{},[22,1145,152],{},[61,1147,1149],{"className":63,"code":1148,"language":65,"meta":66,"style":66},"\u002F\u002F声明可以多次，定义只能一次\n\u002F\u002F声明\nint max(int a, int b);\nint max(int a, int b);\n\u002F\u002F定义\nint max(int a, int b)\n{\n    return a > b ? a : b;\n}\n\nint main() {\n\n    int a = 100;\n    int b = 200;\n\n    cout \u003C\u003C max(a, b) \u003C\u003C endl;\n\n\n    return 0;\n}\n",[68,1150,1151,1156,1161,1183,1203,1208,1228,1232,1253,1257,1261,1269,1273,1285,1298,1302,1317,1321,1325,1333],{"__ignoreMap":66},[71,1152,1153],{"class":73,"line":74},[71,1154,1155],{"class":163},"\u002F\u002F声明可以多次，定义只能一次\n",[71,1157,1158],{"class":73,"line":81},[71,1159,1160],{"class":163},"\u002F\u002F声明\n",[71,1162,1163,1165,1168,1170,1172,1174,1176,1178,1180],{"class":73,"line":87},[71,1164,170],{"class":169},[71,1166,1167],{"class":173}," max",[71,1169,177],{"class":77},[71,1171,170],{"class":169},[71,1173,953],{"class":182},[71,1175,186],{"class":77},[71,1177,170],{"class":169},[71,1179,1069],{"class":182},[71,1181,1182],{"class":77},");\n",[71,1184,1185,1187,1189,1191,1193,1195,1197,1199,1201],{"class":73,"line":94},[71,1186,170],{"class":169},[71,1188,1167],{"class":173},[71,1190,177],{"class":77},[71,1192,170],{"class":169},[71,1194,953],{"class":182},[71,1196,186],{"class":77},[71,1198,170],{"class":169},[71,1200,1069],{"class":182},[71,1202,1182],{"class":77},[71,1204,1205],{"class":73,"line":100},[71,1206,1207],{"class":163},"\u002F\u002F定义\n",[71,1209,1210,1212,1214,1216,1218,1220,1222,1224,1226],{"class":73,"line":105},[71,1211,170],{"class":169},[71,1213,1167],{"class":173},[71,1215,177],{"class":77},[71,1217,170],{"class":169},[71,1219,953],{"class":182},[71,1221,186],{"class":77},[71,1223,170],{"class":169},[71,1225,1069],{"class":182},[71,1227,194],{"class":77},[71,1229,1230],{"class":73,"line":111},[71,1231,84],{"class":77},[71,1233,1234,1236,1238,1241,1243,1246,1248,1251],{"class":73,"line":116},[71,1235,223],{"class":169},[71,1237,346],{"class":77},[71,1239,1240],{"class":169},">",[71,1242,363],{"class":77},[71,1244,1245],{"class":169},"?",[71,1247,346],{"class":77},[71,1249,1250],{"class":169},":",[71,1252,1103],{"class":77},[71,1254,1255],{"class":73,"line":336},[71,1256,119],{"class":77},[71,1258,1259],{"class":73,"line":341},[71,1260,91],{"emptyLinePlaceholder":90},[71,1262,1263,1265,1267],{"class":73,"line":358},[71,1264,170],{"class":169},[71,1266,330],{"class":173},[71,1268,333],{"class":77},[71,1270,1271],{"class":73,"line":372},[71,1272,91],{"emptyLinePlaceholder":90},[71,1274,1275,1277,1279,1281,1283],{"class":73,"line":378},[71,1276,203],{"class":169},[71,1278,346],{"class":77},[71,1280,209],{"class":169},[71,1282,431],{"class":351},[71,1284,355],{"class":77},[71,1286,1287,1289,1291,1293,1296],{"class":73,"line":395},[71,1288,203],{"class":169},[71,1290,363],{"class":77},[71,1292,209],{"class":169},[71,1294,1295],{"class":351}," 200",[71,1297,355],{"class":77},[71,1299,1300],{"class":73,"line":418},[71,1301,91],{"emptyLinePlaceholder":90},[71,1303,1304,1306,1308,1310,1313,1315],{"class":73,"line":423},[71,1305,398],{"class":77},[71,1307,401],{"class":169},[71,1309,1167],{"class":173},[71,1311,1312],{"class":77},"(a, b) ",[71,1314,401],{"class":169},[71,1316,415],{"class":77},[71,1318,1319],{"class":73,"line":436},[71,1320,91],{"emptyLinePlaceholder":90},[71,1322,1323],{"class":73,"line":448},[71,1324,91],{"emptyLinePlaceholder":90},[71,1326,1327,1329,1331],{"class":73,"line":453},[71,1328,223],{"class":169},[71,1330,498],{"class":351},[71,1332,355],{"class":77},[71,1334,1335],{"class":73,"line":466},[71,1336,119],{"class":77},[19,1338,1339],{},[22,1340,124],{},[61,1342,1345],{"className":1343,"code":1344,"language":515,"meta":66},[513],"200\n",[68,1346,1344],{"__ignoreMap":66},[14,1348,1350],{"id":1349},"separating-functions-into-different-files","Separating functions into different files",[19,1352,1353,1355],{},[22,1354,24],{}," To make the code structure clearer.",[19,1357,1358,1359,1362],{},"In the previous chapters, we've mostly been writing code inside ",[68,1360,1361],{},"src\u002Fmain.cpp",". This is good for learning syntax, but once the program gets a bit larger, it becomes messy.",[19,1364,1365],{},"Writing functions in separate files means splitting the code into:",[37,1367,1368,1375,1382],{},[40,1369,1370,1371,1374],{},"Header file ",[68,1372,1373],{},".h",": Write function declarations.",[40,1376,1377,1378,1381],{},"source file ",[68,1379,1380],{},".cpp",": Write function definition.",[40,1383,1384,1387],{},[68,1385,1386],{},"main.cpp",": calling a function.",[19,1389,1390,1391,1396],{},"Starting from ",[1392,1393,1395],"a",{"href":1394},"\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0100-c-kai-fa-huan-jing-da-jian-yu-ce-shi","C++ Development Environment and First Project",", this tutorial has consistently used the same CMake template. By this point in the writing, your project likely still maintains this structure:",[61,1398,1401],{"className":1399,"code":1400,"language":515,"meta":66},[513],"src\u002F\n├── CMakeLists.txt\n├── main.cpp\n├── lib1\u002F\n│   ├── CMakeLists.txt\n│   ├── inc\u002Flib1\u002Feigen3_test.hpp\n│   └── src\u002Feigen3_test.cpp\n└── lib2\u002F\n    ├── CMakeLists.txt\n    ├── inc\u002Flib2\u002Feigen3_test.hpp\n    └── src\u002Feigen3_test.cpp\n",[68,1402,1400],{"__ignoreMap":66},[19,1404,1405,1408,1409,1412,1413,1415,1416,1418,1419,1422,1423,1408,1426,1429],{},[68,1406,1407],{},"lib1"," and ",[68,1410,1411],{},"lib2"," are two sample libraries that come with the template. In this section, we will organize them for the first time: delete the unused ",[68,1414,1411],{},", modify ",[68,1417,1407],{}," into our own ",[68,1420,1421],{},"swap"," library, and rename the template's example header and source files to ",[68,1424,1425],{},"swap.h",[68,1427,1428],{},"swap.cpp"," respectively. These will be used to demonstrate function file separation in this section.",[19,1431,1432],{},"After modification, the directory structure changed as follows:",[61,1434,1437],{"className":1435,"code":1436,"language":515,"meta":66},[513],"src\u002F\n├── CMakeLists.txt\n├── main.cpp\n└── swap\u002F\n    ├── CMakeLists.txt\n    ├── inc\u002Fswap\u002Fswap.h\n    └── src\u002Fswap.cpp\n",[68,1438,1436],{"__ignoreMap":66},[19,1440,1441],{},"In other words:",[37,1443,1444,1450,1458,1473],{},[40,1445,1446,1447,1449],{},"Remove the unused ",[68,1448,1411],{}," from this example.",[40,1451,1452,1453,1455,1456,1141],{},"Rename the ",[68,1454,1407],{}," directory to ",[68,1457,1421],{},[40,1459,1452,1460,1455,1463,1466,1467,1470,1471,1141],{},[68,1461,1462],{},"inc\u002Flib1",[68,1464,1465],{},"inc\u002Fswap",", then rename the ",[68,1468,1469],{},"eigen3_test.hpp"," inside it to ",[68,1472,1425],{},[40,1474,1475,1476,1479,1480,1141],{},"Rename ",[68,1477,1478],{},"src\u002Feigen3_test.cpp"," to ",[68,1481,1482],{},"src\u002Fswap.cpp",[1484,1485,1487],"h4",{"id":1486},"organize-lib1-and-lib2","Organize lib1 and lib2",[19,1489,1490,1491,1493],{},"First, delete ",[68,1492,1411],{},", it's not needed here.",[19,1495,1496],{},[1497,1498],"img",{"alt":1499,"src":1500},"alt text","https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780712796407.webp",[37,1502,1503,1509,1521],{},[40,1504,1452,1505,1455,1507,1250],{},[68,1506,1407],{},[68,1508,1421],{},[40,1510,1452,1511,1455,1513,1515,1516,1518,1519,1250],{},[68,1512,1462],{},[68,1514,1465],{},", and then rename the ",[68,1517,1469],{}," within it to ",[68,1520,1425],{},[40,1522,1475,1523,1479,1525,1250],{},[68,1524,1478],{},[68,1526,1482],{},[19,1528,1529],{},[1497,1530],{"alt":1499,"src":1531},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780712918093.webp",[1484,1533,1535],{"id":1534},"edit-swaph","Edit swap.h",[19,1537,1538],{},"Open:",[61,1540,1543],{"className":1541,"code":1542,"language":515,"meta":66},[513],"src\u002Fswap\u002Finc\u002Fswap\u002Fswap.h\n",[68,1544,1542],{"__ignoreMap":66},[19,1546,1547],{},"Write:",[61,1549,1551],{"className":63,"code":1550,"language":65,"meta":66,"style":66},"#include\u003Ciostream>\nusing namespace std;\n\nvoid swap(int a, int b);\n",[68,1552,1553,1561,1574,1578],{"__ignoreMap":66},[71,1554,1555,1558],{"class":73,"line":74},[71,1556,1557],{"class":169},"#include",[71,1559,1560],{"class":404},"\u003Ciostream>\n",[71,1562,1563,1566,1569,1572],{"class":73,"line":81},[71,1564,1565],{"class":169},"using",[71,1567,1568],{"class":169}," namespace",[71,1570,1571],{"class":173}," std",[71,1573,355],{"class":77},[71,1575,1576],{"class":73,"line":87},[71,1577,91],{"emptyLinePlaceholder":90},[71,1579,1580,1582,1584,1586,1588,1590,1592,1594,1596],{"class":73,"line":94},[71,1581,549],{"class":169},[71,1583,552],{"class":173},[71,1585,177],{"class":77},[71,1587,170],{"class":169},[71,1589,953],{"class":182},[71,1591,186],{"class":77},[71,1593,170],{"class":169},[71,1595,1069],{"class":182},[71,1597,1182],{"class":77},[19,1599,1600],{},[1497,1601],{"alt":1499,"src":1602},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780713074486.webp",[19,1604,1605,1606,1608,1609,1611,1612,1614],{},"This is the first time we've separated function declarations into their own header file. ",[68,1607,1425],{}," is only responsible for informing other source files: there exists a function named ",[68,1610,1421],{}," that takes two ",[68,1613,170],{}," parameters in the project.",[519,1616,1617],{},[19,1618,1619,1620,1623,1624,1626,1627,1630],{},"Additional note: In real engineering projects, it is generally discouraged to use ",[68,1621,1622],{},"using namespace std;"," in header files, and function names like ",[68,1625,1421],{}," should be avoided as well, since the standard library already contains ",[68,1628,1629],{},"std::swap",". However, for now, let’s focus on understanding the workflow of \"declare in the header, define in the source file, and call from the main function.\" Therefore, we’ll temporarily use this simple example code for teaching purposes.",[1484,1632,1634],{"id":1633},"modify-swapcpp","Modify swap.cpp",[19,1636,1538],{},[61,1638,1641],{"className":1639,"code":1640,"language":515,"meta":66},[513],"src\u002Fswap\u002Fsrc\u002Fswap.cpp\n",[68,1642,1640],{"__ignoreMap":66},[19,1644,1547],{},[61,1646,1648],{"className":63,"code":1647,"language":65,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n\nvoid swap(int a, int b)\n{\n    int temp = a;\n    a = b;\n    b = temp;\n\n    cout \u003C\u003C \"a = \" \u003C\u003C a \u003C\u003C endl;\n    cout \u003C\u003C \"b = \" \u003C\u003C b \u003C\u003C endl;\n}\n",[68,1649,1650,1657,1661,1681,1685,1696,1704,1712,1716,1732,1749],{"__ignoreMap":66},[71,1651,1652,1654],{"class":73,"line":74},[71,1653,1557],{"class":169},[71,1655,1656],{"class":404}," \"swap\u002Fswap.h\"\n",[71,1658,1659],{"class":73,"line":81},[71,1660,91],{"emptyLinePlaceholder":90},[71,1662,1663,1665,1667,1669,1671,1673,1675,1677,1679],{"class":73,"line":87},[71,1664,549],{"class":169},[71,1666,552],{"class":173},[71,1668,177],{"class":77},[71,1670,170],{"class":169},[71,1672,953],{"class":182},[71,1674,186],{"class":77},[71,1676,170],{"class":169},[71,1678,1069],{"class":182},[71,1680,194],{"class":77},[71,1682,1683],{"class":73,"line":94},[71,1684,84],{"class":77},[71,1686,1687,1689,1691,1693],{"class":73,"line":100},[71,1688,203],{"class":169},[71,1690,629],{"class":77},[71,1692,209],{"class":169},[71,1694,1695],{"class":77}," a;\n",[71,1697,1698,1700,1702],{"class":73,"line":105},[71,1699,426],{"class":77},[71,1701,209],{"class":169},[71,1703,1103],{"class":77},[71,1705,1706,1708,1710],{"class":73,"line":111},[71,1707,439],{"class":77},[71,1709,209],{"class":169},[71,1711,653],{"class":77},[71,1713,1714],{"class":73,"line":116},[71,1715,91],{"emptyLinePlaceholder":90},[71,1717,1718,1720,1722,1724,1726,1728,1730],{"class":73,"line":336},[71,1719,398],{"class":77},[71,1721,401],{"class":169},[71,1723,981],{"class":404},[71,1725,408],{"class":169},[71,1727,346],{"class":77},[71,1729,401],{"class":169},[71,1731,415],{"class":77},[71,1733,1734,1736,1738,1741,1743,1745,1747],{"class":73,"line":341},[71,1735,398],{"class":77},[71,1737,401],{"class":169},[71,1739,1740],{"class":404}," \"b = \"",[71,1742,408],{"class":169},[71,1744,363],{"class":77},[71,1746,401],{"class":169},[71,1748,415],{"class":77},[71,1750,1751],{"class":73,"line":358},[71,1752,119],{"class":77},[19,1754,1755],{},[1497,1756],{"alt":1499,"src":1757},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780713085999.webp",[19,1759,1760,1761,1764,1765,1767],{},"This ",[68,1762,1763],{},"#include \"swap\u002Fswap.h\""," means: ",[68,1766,1428],{}," must see the function declaration before providing the function definition.",[19,1769,1770,1771,1774,1775,1778],{},"At this point, any VSCode errors can be disregarded. They occur because ",[68,1772,1773],{},"CMakeLists"," hasn't been modified yet, and ",[68,1776,1777],{},"clangd"," also hasn't been refreshed. You can ignore these code hint errors for now.",[1484,1780,1782],{"id":1781},"modify-maincpp","Modify main.cpp",[19,1784,1538],{},[61,1786,1789],{"className":1787,"code":1788,"language":515,"meta":66},[513],"src\u002Fmain.cpp\n",[68,1790,1788],{"__ignoreMap":66},[19,1792,1547],{},[61,1794,1796],{"className":63,"code":1795,"language":65,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n\nint main()\n{\n    int a = 100;\n    int b = 200;\n\n    swap(a, b);\n\n    return 0;\n}\n",[68,1797,1798,1804,1808,1816,1820,1832,1844,1848,1854,1858,1866],{"__ignoreMap":66},[71,1799,1800,1802],{"class":73,"line":74},[71,1801,1557],{"class":169},[71,1803,1656],{"class":404},[71,1805,1806],{"class":73,"line":81},[71,1807,91],{"emptyLinePlaceholder":90},[71,1809,1810,1812,1814],{"class":73,"line":87},[71,1811,170],{"class":169},[71,1813,330],{"class":173},[71,1815,896],{"class":77},[71,1817,1818],{"class":73,"line":94},[71,1819,84],{"class":77},[71,1821,1822,1824,1826,1828,1830],{"class":73,"line":100},[71,1823,203],{"class":169},[71,1825,346],{"class":77},[71,1827,209],{"class":169},[71,1829,431],{"class":351},[71,1831,355],{"class":77},[71,1833,1834,1836,1838,1840,1842],{"class":73,"line":105},[71,1835,203],{"class":169},[71,1837,363],{"class":77},[71,1839,209],{"class":169},[71,1841,1295],{"class":351},[71,1843,355],{"class":77},[71,1845,1846],{"class":73,"line":111},[71,1847,91],{"emptyLinePlaceholder":90},[71,1849,1850,1852],{"class":73,"line":116},[71,1851,765],{"class":173},[71,1853,463],{"class":77},[71,1855,1856],{"class":73,"line":336},[71,1857,91],{"emptyLinePlaceholder":90},[71,1859,1860,1862,1864],{"class":73,"line":341},[71,1861,223],{"class":169},[71,1863,498],{"class":351},[71,1865,355],{"class":77},[71,1867,1868],{"class":73,"line":358},[71,1869,119],{"class":77},[19,1871,1872],{},[22,1873,1874,1875,1877],{},"运行结果（与上面的 ",[68,1876,1428],{}," 一起编译并链接）：",[61,1879,1882],{"className":1880,"code":1881,"language":515,"meta":66},[513],"a = 200\nb = 100\n",[68,1883,1881],{"__ignoreMap":66},[19,1885,1886],{},[1497,1887],{"alt":1499,"src":1888},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780713106888.webp",[19,1890,1891,1893,1894,1896],{},[68,1892,1386],{}," only calls functions and no longer contains the actual implementation of the ",[68,1895,1421],{}," functions within itself.",[1484,1898,1900],{"id":1899},"modify-srcswapcmakeliststxt","Modify src\u002Fswap\u002FCMakeLists.txt.",[19,1902,1538],{},[61,1904,1907],{"className":1905,"code":1906,"language":515,"meta":66},[513],"src\u002Fswap\u002FCMakeLists.txt\n",[68,1908,1906],{"__ignoreMap":66},[19,1910,1911,1912,1914,1915,1917],{},"This file originally came from ",[68,1913,1407],{},", so it still contains traces of ",[68,1916,1407],{}," and Eigen examples.",[19,1919,1920],{},"First, from the first line:",[61,1922,1926],{"className":1923,"code":1924,"language":1925,"meta":66,"style":66},"language-cmake shiki shiki-themes github-light github-dark","set(PREFIX \"lib1\")\n","cmake",[68,1927,1928],{"__ignoreMap":66},[71,1929,1930,1933,1935,1938,1941],{"class":73,"line":74},[71,1931,1932],{"class":169},"set",[71,1934,177],{"class":77},[71,1936,1937],{"class":173},"PREFIX",[71,1939,1940],{"class":404}," \"lib1\"",[71,1942,194],{"class":77},[19,1944,1945],{},"Please provide the Simplified Chinese Markdown fragment you'd like me to translate.",[61,1947,1949],{"className":1923,"code":1948,"language":1925,"meta":66,"style":66},"set(PREFIX \"swap\")\n",[68,1950,1951],{"__ignoreMap":66},[71,1952,1953,1955,1957,1959,1962],{"class":73,"line":74},[71,1954,1932],{"class":169},[71,1956,177],{"class":77},[71,1958,1937],{"class":173},[71,1960,1961],{"class":404}," \"swap\"",[71,1963,194],{"class":77},[19,1965,1966],{},"这样 CMake 会创建一个名为：",[61,1968,1971],{"className":1969,"code":1970,"language":515,"meta":66},[513],"swap_src_lib\n",[68,1972,1970],{"__ignoreMap":66},[19,1974,1975],{},"library.",[19,1977,1978,1979,1982],{},"This example does not require Eigen, so remove the Eigen dependency from the ",[68,1980,1981],{},"Third-party dependencies"," block:",[61,1984,1986],{"className":1923,"code":1985,"language":1925,"meta":66,"style":66},"find_package(Eigen3 REQUIRED)\n\ntarget_link_libraries(${PREFIX}_src_lib\n  PUBLIC\n    Eigen3::Eigen\n)\n",[68,1987,1988,1996,2000,2013,2018,2023],{"__ignoreMap":66},[71,1989,1990,1993],{"class":73,"line":74},[71,1991,1992],{"class":169},"find_package",[71,1994,1995],{"class":77},"(Eigen3 REQUIRED)\n",[71,1997,1998],{"class":73,"line":81},[71,1999,91],{"emptyLinePlaceholder":90},[71,2001,2002,2005,2007,2010],{"class":73,"line":87},[71,2003,2004],{"class":169},"target_link_libraries",[71,2006,177],{"class":77},[71,2008,2009],{"class":169},"${PREFIX}",[71,2011,2012],{"class":77},"_src_lib\n",[71,2014,2015],{"class":73,"line":94},[71,2016,2017],{"class":173},"  PUBLIC\n",[71,2019,2020],{"class":73,"line":100},[71,2021,2022],{"class":77},"    Eigen3::Eigen\n",[71,2024,2025],{"class":73,"line":105},[71,2026,194],{"class":77},[19,2028,2029],{},"Only modify the above two items; no need to modify the rest. Here is an introduction to some key points:",[19,2031,2032,2033,2036],{},"After organization, ",[68,2034,2035],{},"src\u002Fswap\u002FCMakeLists.txt"," can be written as:",[61,2038,2040],{"className":1923,"code":2039,"language":1925,"meta":66,"style":66},"set(PREFIX \"swap\")\n\nfile(GLOB_RECURSE ${PREFIX}_SRC_LIST CONFIGURE_DEPENDS\n  \"${CMAKE_CURRENT_LIST_DIR}\u002Fsrc\u002F*.c\"\n  \"${CMAKE_CURRENT_LIST_DIR}\u002Fsrc\u002F*.cpp\"\n)\n\nadd_library(${PREFIX}_src_lib SHARED\n  ${${PREFIX}_SRC_LIST}\n)\n\ntarget_include_directories(${PREFIX}_src_lib\n  PUBLIC\n    $\u003CBUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}\u002Finc>\n    $\u003CINSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>\n)\n\ntarget_link_libraries(${PREFIX}_src_lib\n  PUBLIC\n    project_options\n  PRIVATE\n    project_warnings\n)\n\n# ========================\n# Third-party dependencies\n# ========================\n\n# =======\n# Install\n# =======\ninstall(TARGETS ${PREFIX}_src_lib\n  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}\n  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}\n  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}\n)\n\ninstall(DIRECTORY \"${CMAKE_CURRENT_LIST_DIR}\u002Finc\u002F\"\n  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}\n)\n",[68,2041,2042,2054,2058,2071,2076,2081,2085,2089,2101,2111,2115,2119,2130,2134,2145,2156,2160,2164,2174,2178,2183,2188,2193,2197,2201,2206,2211,2215,2219,2224,2229,2234,2247,2256,2264,2273,2278,2283,2294,2303],{"__ignoreMap":66},[71,2043,2044,2046,2048,2050,2052],{"class":73,"line":74},[71,2045,1932],{"class":169},[71,2047,177],{"class":77},[71,2049,1937],{"class":173},[71,2051,1961],{"class":404},[71,2053,194],{"class":77},[71,2055,2056],{"class":73,"line":81},[71,2057,91],{"emptyLinePlaceholder":90},[71,2059,2060,2063,2066,2068],{"class":73,"line":87},[71,2061,2062],{"class":169},"file",[71,2064,2065],{"class":77},"(GLOB_RECURSE ",[71,2067,2009],{"class":169},[71,2069,2070],{"class":77},"_SRC_LIST CONFIGURE_DEPENDS\n",[71,2072,2073],{"class":73,"line":94},[71,2074,2075],{"class":404},"  \"${CMAKE_CURRENT_LIST_DIR}\u002Fsrc\u002F*.c\"\n",[71,2077,2078],{"class":73,"line":100},[71,2079,2080],{"class":404},"  \"${CMAKE_CURRENT_LIST_DIR}\u002Fsrc\u002F*.cpp\"\n",[71,2082,2083],{"class":73,"line":105},[71,2084,194],{"class":77},[71,2086,2087],{"class":73,"line":111},[71,2088,91],{"emptyLinePlaceholder":90},[71,2090,2091,2094,2096,2098],{"class":73,"line":116},[71,2092,2093],{"class":169},"add_library",[71,2095,177],{"class":77},[71,2097,2009],{"class":169},[71,2099,2100],{"class":77},"_src_lib SHARED\n",[71,2102,2103,2106,2108],{"class":73,"line":336},[71,2104,2105],{"class":77},"  ${",[71,2107,2009],{"class":169},[71,2109,2110],{"class":77},"_SRC_LIST}\n",[71,2112,2113],{"class":73,"line":341},[71,2114,194],{"class":77},[71,2116,2117],{"class":73,"line":358},[71,2118,91],{"emptyLinePlaceholder":90},[71,2120,2121,2124,2126,2128],{"class":73,"line":372},[71,2122,2123],{"class":169},"target_include_directories",[71,2125,177],{"class":77},[71,2127,2009],{"class":169},[71,2129,2012],{"class":77},[71,2131,2132],{"class":73,"line":378},[71,2133,2017],{"class":173},[71,2135,2136,2139,2142],{"class":73,"line":395},[71,2137,2138],{"class":77},"    $\u003CBUILD_INTERFACE:",[71,2140,2141],{"class":169},"${CMAKE_CURRENT_LIST_DIR}",[71,2143,2144],{"class":77},"\u002Finc>\n",[71,2146,2147,2150,2153],{"class":73,"line":418},[71,2148,2149],{"class":77},"    $\u003CINSTALL_INTERFACE:",[71,2151,2152],{"class":169},"${CMAKE_INSTALL_INCLUDEDIR}",[71,2154,2155],{"class":77},">\n",[71,2157,2158],{"class":73,"line":423},[71,2159,194],{"class":77},[71,2161,2162],{"class":73,"line":436},[71,2163,91],{"emptyLinePlaceholder":90},[71,2165,2166,2168,2170,2172],{"class":73,"line":448},[71,2167,2004],{"class":169},[71,2169,177],{"class":77},[71,2171,2009],{"class":169},[71,2173,2012],{"class":77},[71,2175,2176],{"class":73,"line":453},[71,2177,2017],{"class":173},[71,2179,2180],{"class":73,"line":466},[71,2181,2182],{"class":77},"    project_options\n",[71,2184,2185],{"class":73,"line":483},[71,2186,2187],{"class":173},"  PRIVATE\n",[71,2189,2190],{"class":73,"line":488},[71,2191,2192],{"class":77},"    project_warnings\n",[71,2194,2195],{"class":73,"line":493},[71,2196,194],{"class":77},[71,2198,2199],{"class":73,"line":503},[71,2200,91],{"emptyLinePlaceholder":90},[71,2202,2203],{"class":73,"line":774},[71,2204,2205],{"class":163},"# ========================\n",[71,2207,2208],{"class":73,"line":792},[71,2209,2210],{"class":163},"# Third-party dependencies\n",[71,2212,2213],{"class":73,"line":810},[71,2214,2205],{"class":163},[71,2216,2217],{"class":73,"line":815},[71,2218,91],{"emptyLinePlaceholder":90},[71,2220,2221],{"class":73,"line":820},[71,2222,2223],{"class":163},"# =======\n",[71,2225,2226],{"class":73,"line":829},[71,2227,2228],{"class":163},"# Install\n",[71,2230,2232],{"class":73,"line":2231},31,[71,2233,2223],{"class":163},[71,2235,2237,2240,2243,2245],{"class":73,"line":2236},32,[71,2238,2239],{"class":169},"install",[71,2241,2242],{"class":77},"(TARGETS ",[71,2244,2009],{"class":169},[71,2246,2012],{"class":77},[71,2248,2250,2253],{"class":73,"line":2249},33,[71,2251,2252],{"class":77},"  LIBRARY DESTINATION ",[71,2254,2255],{"class":169},"${CMAKE_INSTALL_LIBDIR}\n",[71,2257,2259,2262],{"class":73,"line":2258},34,[71,2260,2261],{"class":77},"  ARCHIVE DESTINATION ",[71,2263,2255],{"class":169},[71,2265,2267,2270],{"class":73,"line":2266},35,[71,2268,2269],{"class":77},"  RUNTIME DESTINATION ",[71,2271,2272],{"class":169},"${CMAKE_INSTALL_BINDIR}\n",[71,2274,2276],{"class":73,"line":2275},36,[71,2277,194],{"class":77},[71,2279,2281],{"class":73,"line":2280},37,[71,2282,91],{"emptyLinePlaceholder":90},[71,2284,2286,2288,2291],{"class":73,"line":2285},38,[71,2287,2239],{"class":169},[71,2289,2290],{"class":77},"(DIRECTORY ",[71,2292,2293],{"class":404},"\"${CMAKE_CURRENT_LIST_DIR}\u002Finc\u002F\"\n",[71,2295,2297,2300],{"class":73,"line":2296},39,[71,2298,2299],{"class":77},"  DESTINATION ",[71,2301,2302],{"class":169},"${CMAKE_INSTALL_INCLUDEDIR}\n",[71,2304,2306],{"class":73,"line":2305},40,[71,2307,194],{"class":77},[19,2309,2310],{},"The most important lines here are:",[61,2312,2314],{"className":1923,"code":2313,"language":1925,"meta":66,"style":66},"file(GLOB_RECURSE ${PREFIX}_SRC_LIST CONFIGURE_DEPENDS\n  \"${CMAKE_CURRENT_LIST_DIR}\u002Fsrc\u002F*.c\"\n  \"${CMAKE_CURRENT_LIST_DIR}\u002Fsrc\u002F*.cpp\"\n)\n",[68,2315,2316,2326,2330,2334],{"__ignoreMap":66},[71,2317,2318,2320,2322,2324],{"class":73,"line":74},[71,2319,2062],{"class":169},[71,2321,2065],{"class":77},[71,2323,2009],{"class":169},[71,2325,2070],{"class":77},[71,2327,2328],{"class":73,"line":81},[71,2329,2075],{"class":404},[71,2331,2332],{"class":73,"line":87},[71,2333,2080],{"class":404},[71,2335,2336],{"class":73,"line":94},[71,2337,194],{"class":77},[19,2339,2340,2341,2343,2344,2347,2348,2350],{},"It will collect the ",[68,2342,1380],{}," files from inside ",[68,2345,2346],{},"src\u002Fswap\u002Fsrc\u002F",", so ",[68,2349,1428],{}," will be compiled.",[19,2352,2353],{},"Additionally:",[61,2355,2357],{"className":1923,"code":2356,"language":1925,"meta":66,"style":66},"target_include_directories(${PREFIX}_src_lib\n  PUBLIC\n    $\u003CBUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}\u002Finc>\n    $\u003CINSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>\n)\n",[68,2358,2359,2369,2373,2381,2389],{"__ignoreMap":66},[71,2360,2361,2363,2365,2367],{"class":73,"line":74},[71,2362,2123],{"class":169},[71,2364,177],{"class":77},[71,2366,2009],{"class":169},[71,2368,2012],{"class":77},[71,2370,2371],{"class":73,"line":81},[71,2372,2017],{"class":173},[71,2374,2375,2377,2379],{"class":73,"line":87},[71,2376,2138],{"class":77},[71,2378,2141],{"class":169},[71,2380,2144],{"class":77},[71,2382,2383,2385,2387],{"class":73,"line":94},[71,2384,2149],{"class":77},[71,2386,2152],{"class":169},[71,2388,2155],{"class":77},[71,2390,2391],{"class":73,"line":100},[71,2392,194],{"class":77},[19,2394,2395,2396,2399],{},"It adds ",[68,2397,2398],{},"src\u002Fswap\u002Finc\u002F"," to the header file search path, so in the code you can write:",[61,2401,2403],{"className":63,"code":2402,"language":65,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n",[68,2404,2405],{"__ignoreMap":66},[71,2406,2407,2409],{"class":73,"line":74},[71,2408,1557],{"class":169},[71,2410,1656],{"class":404},[19,2412,2413,2414,2417,2418,2420,2421,2424,2425,1141],{},"Note: Do not write as ",[68,2415,2416],{},"#include \"inc\u002Fswap\u002Fswap.h\"",". CMake has already told the compiler ",[68,2419,2398],{},", so when including, continue writing from ",[68,2422,2423],{},"inc\u002F"," onwards, which means ",[68,2426,2427],{},"swap\u002Fswap.h",[19,2429,2430,2431,2435,2436,2438,2439,2442,2443,2445],{},"The complete CMake syntax will be systematically explained in the ",[1392,2432,2434],{"href":2433},"\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2200-cmake-gong-cheng-mu-ban","CMake project template",". For now, just know that \"header files go into ",[68,2437,2423],{},", source files go into ",[68,2440,2441],{},"src\u002F",", and the library name is determined by ",[68,2444,1937],{},".\"",[1484,2447,2449],{"id":2448},"modify-srccmakeliststxt","Modify src\u002FCMakeLists.txt",[19,2451,1538],{},[61,2453,2456],{"className":2454,"code":2455,"language":515,"meta":66},[513],"src\u002FCMakeLists.txt\n",[68,2457,2455],{"__ignoreMap":66},[19,2459,2460],{},"Originally, the template contained:",[61,2462,2464],{"className":1923,"code":2463,"language":1925,"meta":66,"style":66},"add_subdirectory(lib1)\nadd_subdirectory(lib2)\n",[68,2465,2466,2474],{"__ignoreMap":66},[71,2467,2468,2471],{"class":73,"line":74},[71,2469,2470],{"class":169},"add_subdirectory",[71,2472,2473],{"class":77},"(lib1)\n",[71,2475,2476,2478],{"class":73,"line":81},[71,2477,2470],{"class":169},[71,2479,2480],{"class":77},"(lib2)\n",[19,2482,1945],{},[61,2484,2486],{"className":1923,"code":2485,"language":1925,"meta":66,"style":66},"add_subdirectory(swap)\n",[68,2487,2488],{"__ignoreMap":66},[71,2489,2490,2492],{"class":73,"line":74},[71,2491,2470],{"class":169},[71,2493,2494],{"class":77},"(swap)\n",[19,2496,2497,2498,2500,2501,2503,2504,2506],{},"The original template allowed ",[68,2499,1407],{}," to call ",[68,2502,1411],{},", but now ",[68,2505,1411],{}," is gone, so remove this part:",[61,2508,2510],{"className":1923,"code":2509,"language":1925,"meta":66,"style":66},"target_link_libraries(lib1_src_lib\n  PRIVATE\n    lib2_src_lib\n)\n",[68,2511,2512,2519,2523,2528],{"__ignoreMap":66},[71,2513,2514,2516],{"class":73,"line":74},[71,2515,2004],{"class":169},[71,2517,2518],{"class":77},"(lib1_src_lib\n",[71,2520,2521],{"class":73,"line":81},[71,2522,2187],{"class":173},[71,2524,2525],{"class":73,"line":87},[71,2526,2527],{"class":77},"    lib2_src_lib\n",[71,2529,2530],{"class":73,"line":94},[71,2531,194],{"class":77},[19,2533,2534],{},"Please specify which part you would like me to delete.",[19,2536,2537],{},"It turns out the template even links:",[61,2539,2541],{"className":1923,"code":2540,"language":1925,"meta":66,"style":66},"target_link_libraries(${PROJECT_NAME}\n  PRIVATE\n    lib1_src_lib\n    lib2_src_lib\n)\n",[68,2542,2543,2552,2556,2561,2565],{"__ignoreMap":66},[71,2544,2545,2547,2549],{"class":73,"line":74},[71,2546,2004],{"class":169},[71,2548,177],{"class":77},[71,2550,2551],{"class":169},"${PROJECT_NAME}\n",[71,2553,2554],{"class":73,"line":81},[71,2555,2187],{"class":173},[71,2557,2558],{"class":73,"line":87},[71,2559,2560],{"class":77},"    lib1_src_lib\n",[71,2562,2563],{"class":73,"line":94},[71,2564,2527],{"class":77},[71,2566,2567],{"class":73,"line":100},[71,2568,194],{"class":77},[19,2570,1945],{},[61,2572,2574],{"className":1923,"code":2573,"language":1925,"meta":66,"style":66},"target_link_libraries(${PROJECT_NAME}\n  PRIVATE\n    swap_src_lib\n)\n",[68,2575,2576,2584,2588,2593],{"__ignoreMap":66},[71,2577,2578,2580,2582],{"class":73,"line":74},[71,2579,2004],{"class":169},[71,2581,177],{"class":77},[71,2583,2551],{"class":169},[71,2585,2586],{"class":73,"line":81},[71,2587,2187],{"class":173},[71,2589,2590],{"class":73,"line":87},[71,2591,2592],{"class":77},"    swap_src_lib\n",[71,2594,2595],{"class":73,"line":94},[71,2596,194],{"class":77},[19,2598,2599],{},"Only modify the three items mentioned above, everything else remains unchanged. Now, let me introduce the key points:",[19,2601,2032,2602,2036],{},[68,2603,2604],{},"src\u002FCMakeLists.txt",[61,2606,2608],{"className":1923,"code":2607,"language":1925,"meta":66,"style":66},"add_executable(${PROJECT_NAME}\n  ${CMAKE_CURRENT_SOURCE_DIR}\u002Fmain.cpp\n)\n\ntarget_link_libraries(${PROJECT_NAME}\n  PRIVATE\n    project_options\n    project_warnings\n)\n\nadd_subdirectory(swap)\n\ntarget_link_libraries(${PROJECT_NAME}\n  PRIVATE\n    swap_src_lib\n)\n\nset_target_properties(${PROJECT_NAME} PROPERTIES\n  INSTALL_RPATH \"$ORIGIN\u002F..\u002F${CMAKE_INSTALL_LIBDIR}\"\n)\n\ninstall(TARGETS ${PROJECT_NAME}\n  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}\n)\n",[68,2609,2610,2619,2627,2631,2635,2643,2647,2651,2655,2659,2663,2669,2673,2681,2685,2689,2693,2697,2710,2718,2722,2726,2734,2740],{"__ignoreMap":66},[71,2611,2612,2615,2617],{"class":73,"line":74},[71,2613,2614],{"class":169},"add_executable",[71,2616,177],{"class":77},[71,2618,2551],{"class":169},[71,2620,2621,2624],{"class":73,"line":81},[71,2622,2623],{"class":169},"  ${CMAKE_CURRENT_SOURCE_DIR}",[71,2625,2626],{"class":77},"\u002Fmain.cpp\n",[71,2628,2629],{"class":73,"line":87},[71,2630,194],{"class":77},[71,2632,2633],{"class":73,"line":94},[71,2634,91],{"emptyLinePlaceholder":90},[71,2636,2637,2639,2641],{"class":73,"line":100},[71,2638,2004],{"class":169},[71,2640,177],{"class":77},[71,2642,2551],{"class":169},[71,2644,2645],{"class":73,"line":105},[71,2646,2187],{"class":173},[71,2648,2649],{"class":73,"line":111},[71,2650,2182],{"class":77},[71,2652,2653],{"class":73,"line":116},[71,2654,2192],{"class":77},[71,2656,2657],{"class":73,"line":336},[71,2658,194],{"class":77},[71,2660,2661],{"class":73,"line":341},[71,2662,91],{"emptyLinePlaceholder":90},[71,2664,2665,2667],{"class":73,"line":358},[71,2666,2470],{"class":169},[71,2668,2494],{"class":77},[71,2670,2671],{"class":73,"line":372},[71,2672,91],{"emptyLinePlaceholder":90},[71,2674,2675,2677,2679],{"class":73,"line":378},[71,2676,2004],{"class":169},[71,2678,177],{"class":77},[71,2680,2551],{"class":169},[71,2682,2683],{"class":73,"line":395},[71,2684,2187],{"class":173},[71,2686,2687],{"class":73,"line":418},[71,2688,2592],{"class":77},[71,2690,2691],{"class":73,"line":423},[71,2692,194],{"class":77},[71,2694,2695],{"class":73,"line":436},[71,2696,91],{"emptyLinePlaceholder":90},[71,2698,2699,2702,2704,2707],{"class":73,"line":448},[71,2700,2701],{"class":169},"set_target_properties",[71,2703,177],{"class":77},[71,2705,2706],{"class":169},"${PROJECT_NAME}",[71,2708,2709],{"class":77}," PROPERTIES\n",[71,2711,2712,2715],{"class":73,"line":453},[71,2713,2714],{"class":182},"  INSTALL_RPATH",[71,2716,2717],{"class":404}," \"$ORIGIN\u002F..\u002F${CMAKE_INSTALL_LIBDIR}\"\n",[71,2719,2720],{"class":73,"line":466},[71,2721,194],{"class":77},[71,2723,2724],{"class":73,"line":483},[71,2725,91],{"emptyLinePlaceholder":90},[71,2727,2728,2730,2732],{"class":73,"line":488},[71,2729,2239],{"class":169},[71,2731,2242],{"class":77},[71,2733,2551],{"class":169},[71,2735,2736,2738],{"class":73,"line":493},[71,2737,2269],{"class":77},[71,2739,2272],{"class":169},[71,2741,2742],{"class":73,"line":503},[71,2743,194],{"class":77},[19,2745,2746],{},"These two points are most critical:",[61,2748,2749],{"className":1923,"code":2485,"language":1925,"meta":66,"style":66},[68,2750,2751],{"__ignoreMap":66},[71,2752,2753,2755],{"class":73,"line":74},[71,2754,2470],{"class":169},[71,2756,2494],{"class":77},[19,2758,2759,2760,2763,2764,1141],{},"This means: have CMake go into ",[68,2761,2762],{},"src\u002Fswap\u002F"," and read ",[68,2765,2035],{},[61,2767,2768],{"className":1923,"code":2573,"language":1925,"meta":66,"style":66},[68,2769,2770,2778,2782,2786],{"__ignoreMap":66},[71,2771,2772,2774,2776],{"class":73,"line":74},[71,2773,2004],{"class":169},[71,2775,177],{"class":77},[71,2777,2551],{"class":169},[71,2779,2780],{"class":73,"line":81},[71,2781,2187],{"class":173},[71,2783,2784],{"class":73,"line":87},[71,2785,2592],{"class":77},[71,2787,2788],{"class":73,"line":94},[71,2789,194],{"class":77},[19,2791,2792,2793,2795,2796,2799,2800,2802],{},"This means that the main program has called the ",[68,2794,1421],{}," function, so the main program must link with ",[68,2797,2798],{},"swap_src_lib","; otherwise, the linker will not be able to find the definition of the ",[68,2801,1421],{}," function.",[1484,2804,2806],{"id":2805},"rebuild-and-run","Rebuild and run",[19,2808,2809],{},"Compile",[19,2811,2812],{},[1497,2813],{"alt":1499,"src":2814},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780713420848.webp",[19,2816,2817],{},"At this point, the code suggestions from clangd will no longer show errors.",[19,2819,2820],{},[1497,2821],{"alt":1499,"src":2822},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780713445608.webp",[19,2824,2825],{},"Then run:",[19,2827,2828],{},[1497,2829],{"alt":1499,"src":2830},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780713490504.webp",[19,2832,2833],{},"Output similar to:",[61,2835,2837],{"className":2836,"code":1881,"language":515,"meta":66},[513],[68,2838,1881],{"__ignoreMap":66},[19,2840,2841,2842,2844],{},"As can be seen, the functions in ",[68,2843,1428],{}," are indeed being called by the main program.",[1484,2846,2848],{"id":2847},"core-understanding-of-writing-in-separate-files","Core understanding of writing in separate files",[19,2850,2851],{},"In this template, splitting functions into separate files isn't just about dividing the files—you also need to ensure CMake recognizes which files belong to which library.",[19,2853,2854],{},"The corresponding relationship is as follows:",[2856,2857,2858,2871],"table",{},[2859,2860,2861],"thead",{},[2862,2863,2864,2868],"tr",{},[2865,2866,2062],"th",{"align":2867},"left",[2865,2869,2870],{"align":2867},"effect",[2872,2873,2874,2888,2898,2912,2924],"tbody",{},[2862,2875,2876,2882],{},[2877,2878,2879],"td",{"align":2867},[68,2880,2881],{},"src\u002Fswap\u002Finc\u002Fswap\u002Fswap.h",[2877,2883,2884,2885,2887],{"align":2867},"Write function declarations so that other ",[68,2886,1380],{}," files know how to call them.",[2862,2889,2890,2895],{},[2877,2891,2892],{"align":2867},[68,2893,2894],{},"src\u002Fswap\u002Fsrc\u002Fswap.cpp",[2877,2896,2897],{"align":2867},"Write function definitions and provide actual implementations.",[2862,2899,2900,2904],{},[2877,2901,2902],{"align":2867},[68,2903,2035],{},[2877,2905,2906,2907,2909,2910,1141],{"align":2867},"Compile ",[68,2908,1428],{}," into ",[68,2911,2798],{},[2862,2913,2914,2918],{},[2877,2915,2916],{"align":2867},[68,2917,2604],{},[2877,2919,2920,2921,2923],{"align":2867},"Link ",[68,2922,2798],{}," to the main program.",[2862,2925,2926,2930],{},[2877,2927,2928],{"align":2867},[68,2929,1361],{},[2877,2931,2932,2933],{"align":2867},"Then call ",[68,2934,2935],{},"swap(a, b)",[19,2937,2938,2939,2941,2942,2802],{},"If ",[68,2940,1763],{}," is omitted, the compiler doesn't know the declaration of the ",[68,2943,1421],{},[19,2945,2938,2946,2949,2950,1141],{},[68,2947,2948],{},"add_subdirectory(swap)"," is omitted, CMake will not enter ",[68,2951,2952],{},"src\u002Fswap",[19,2954,2955],{},"If missed:",[61,2957,2958],{"className":1923,"code":2573,"language":1925,"meta":66,"style":66},[68,2959,2960,2968,2972,2976],{"__ignoreMap":66},[71,2961,2962,2964,2966],{"class":73,"line":74},[71,2963,2004],{"class":169},[71,2965,177],{"class":77},[71,2967,2551],{"class":169},[71,2969,2970],{"class":73,"line":81},[71,2971,2187],{"class":173},[71,2973,2974],{"class":73,"line":87},[71,2975,2592],{"class":77},[71,2977,2978],{"class":73,"line":94},[71,2979,194],{"class":77},[19,2981,2982,2983,1141],{},"The linker cannot find the implementation of function ",[68,2984,1421],{},[10,2986,2988],{"id":2987},"organization-of-header-files","Organization of Header Files",[19,2990,2991,2992,2994,2995,2997,2998,1141],{},"We just placed the declaration of the ",[68,2993,1421],{}," function into ",[68,2996,1425],{},". Other source files, as long as they include this header file, can know which functions this library provides. These functions, types, and variables provided for use by external code are commonly referred to as the library's ",[22,2999,3000],{},"API",[19,3002,3003],{},"Header files generally are responsible for containing:",[37,3005,3006,3009,3012,3015],{},[40,3007,3008],{},"Function declaration.",[40,3010,3011],{},"Declarations or definitions of types, structs, and classes.",[40,3013,3014],{},"Necessary constant and variable declarations.",[40,3016,3017],{},"Other header files required by these declarations.",[19,3019,3020,3021,3024,3025,3027],{},"Header files cannot be executed on their own. After modifying a header file, you need to recompile the ",[68,3022,3023],{},".c"," or ",[68,3026,1380],{}," file that includes it to verify the changes.",[14,3029,3031],{"id":3030},"header-files-in-a-pure-c-project","Header files in a pure C++ project",[19,3033,3034,3035,3037,3038,3040,3041,3043],{},"The library in this chapter ",[68,3036,1421],{}," is implemented by ",[68,3039,1428],{}," and called by ",[68,3042,1386],{},". All source files are compiled as C++ code. Therefore, let's first look at the complete writing of a standard C++ header file.",[19,3045,3046],{},"Pure C++ projects are recommended to use the following header file template.",[61,3048,3050],{"className":63,"code":3049,"language":65,"meta":66,"style":66},"#ifndef __FILE_NAME_H_  \u002F\u002F 防止头文件被重复包含，使用时要修改宏名\n#define __FILE_NAME_H_\n\n\u002F* 头文件内容开始 *\u002F\n\n\u002F\u002F 在这里编写必要的预处理指令、类型定义、函数声明和变量声明\n\n\u002F* 头文件内容结束 *\u002F\n\n#endif  \u002F\u002F __FILE_NAME_H_\n",[68,3051,3052,3063,3071,3075,3080,3084,3089,3093,3098,3102],{"__ignoreMap":66},[71,3053,3054,3057,3060],{"class":73,"line":74},[71,3055,3056],{"class":169},"#ifndef",[71,3058,3059],{"class":173}," __FILE_NAME_H_",[71,3061,3062],{"class":163},"  \u002F\u002F 防止头文件被重复包含，使用时要修改宏名\n",[71,3064,3065,3068],{"class":73,"line":81},[71,3066,3067],{"class":169},"#define",[71,3069,3070],{"class":173}," __FILE_NAME_H_\n",[71,3072,3073],{"class":73,"line":87},[71,3074,91],{"emptyLinePlaceholder":90},[71,3076,3077],{"class":73,"line":94},[71,3078,3079],{"class":163},"\u002F* 头文件内容开始 *\u002F\n",[71,3081,3082],{"class":73,"line":100},[71,3083,91],{"emptyLinePlaceholder":90},[71,3085,3086],{"class":73,"line":105},[71,3087,3088],{"class":163},"\u002F\u002F 在这里编写必要的预处理指令、类型定义、函数声明和变量声明\n",[71,3090,3091],{"class":73,"line":111},[71,3092,91],{"emptyLinePlaceholder":90},[71,3094,3095],{"class":73,"line":116},[71,3096,3097],{"class":163},"\u002F* 头文件内容结束 *\u002F\n",[71,3099,3100],{"class":73,"line":336},[71,3101,91],{"emptyLinePlaceholder":90},[71,3103,3104,3107],{"class":73,"line":341},[71,3105,3106],{"class":169},"#endif",[71,3108,3109],{"class":163},"  \u002F\u002F __FILE_NAME_H_\n",[19,3111,3112],{},"When using the template, modify the protection macro based on the actual filename. For example:",[131,3114,3115,3123],{},[40,3116,3117,3119,3120,1141],{},[68,3118,1425],{}," can use ",[68,3121,3122],{},"__SWAP_H_",[40,3124,3125,3119,3128,1141],{},[68,3126,3127],{},"camera.hpp",[68,3129,3130],{},"__CAMERA_HPP_",[19,3132,3133,3134,3136],{},"This chapter's ",[68,3135,1425],{}," can be organized as:",[61,3138,3140],{"className":63,"code":3139,"language":65,"meta":66,"style":66},"#ifndef __SWAP_H_\n#define __SWAP_H_\n\n#include \u003Ciostream>\nusing namespace std;\n\nvoid swap(int a, int b);\n\n#endif  \u002F\u002F __SWAP_H_\n",[68,3141,3142,3149,3155,3159,3166,3176,3180,3200,3204],{"__ignoreMap":66},[71,3143,3144,3146],{"class":73,"line":74},[71,3145,3056],{"class":169},[71,3147,3148],{"class":173}," __SWAP_H_\n",[71,3150,3151,3153],{"class":73,"line":81},[71,3152,3067],{"class":169},[71,3154,3148],{"class":173},[71,3156,3157],{"class":73,"line":87},[71,3158,91],{"emptyLinePlaceholder":90},[71,3160,3161,3163],{"class":73,"line":94},[71,3162,1557],{"class":169},[71,3164,3165],{"class":404}," \u003Ciostream>\n",[71,3167,3168,3170,3172,3174],{"class":73,"line":100},[71,3169,1565],{"class":169},[71,3171,1568],{"class":169},[71,3173,1571],{"class":173},[71,3175,355],{"class":77},[71,3177,3178],{"class":73,"line":105},[71,3179,91],{"emptyLinePlaceholder":90},[71,3181,3182,3184,3186,3188,3190,3192,3194,3196,3198],{"class":73,"line":111},[71,3183,549],{"class":169},[71,3185,552],{"class":173},[71,3187,177],{"class":77},[71,3189,170],{"class":169},[71,3191,953],{"class":182},[71,3193,186],{"class":77},[71,3195,170],{"class":169},[71,3197,1069],{"class":182},[71,3199,1182],{"class":77},[71,3201,3202],{"class":73,"line":116},[71,3203,91],{"emptyLinePlaceholder":90},[71,3205,3206,3208],{"class":73,"line":336},[71,3207,3106],{"class":169},[71,3209,3210],{"class":163},"  \u002F\u002F __SWAP_H_\n",[19,3212,3213],{},"Now this is the most standardized form of a C++ header file.",[19,3215,3216],{},"After compilation and execution:",[19,3218,3219],{},[1497,3220],{"alt":1499,"src":3221},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780715053871.webp",[19,3223,3224,3225,1408,3227,3229,3230,3232,3233,3236],{},"The ",[68,3226,3056],{},[68,3228,3067],{}," at the beginning, along with the ",[68,3231,3106],{}," at the end, form a ",[22,3234,3235],{},"header file protection macro",". This ensures that even if the same header file is included indirectly multiple times, its contents are compiled only once, preventing issues such as duplicate definitions.",[19,3238,3239,3240,3243,3244,3246],{},"In pure C++ projects, the ",[68,3241,3242],{},".hpp"," extension is also commonly used to emphasize that it is a C++ header file; ",[68,3245,1373],{}," can likewise be used. A project's own header files should generally retain their extensions, for example:",[61,3248,3249],{"className":63,"code":2402,"language":65,"meta":66,"style":66},[68,3250,3251],{"__ignoreMap":66},[71,3252,3253,3255],{"class":73,"line":74},[71,3254,1557],{"class":169},[71,3256,1656],{"class":404},[19,3258,3259,3260,186,3263,3266],{},"The names ",[68,3261,3262],{},"\u003Ciostream>",[68,3264,3265],{},"\u003Cstring>",", and similar in the standard library have no file extension—this is the naming convention dictated by the C++ standard. It does not imply that header files in your project should also omit extensions.",[14,3268,3270],{"id":3269},"c-interfaces-and-header-files-for-mixed-cc-projects","C interfaces and header files for mixed C\u002FC++ projects",[19,3272,3273,3274,1408,3276,3278,3279,3282,3283,3285,3286,3289,3290,3292],{},"In a project, both ",[68,3275,3023],{},[68,3277,1380],{}," files can exist. For example, a C++ source file ",[68,3280,3281],{},"xxx.cpp"," can call functions from an ",[68,3284,3023],{}," file, and an ",[68,3287,3288],{},"main.c"," file can call functions from an ",[68,3291,1380],{}," file.",[19,3294,3295],{},"However, C and C++ compilers handle function names differently. Whenever a call crosses the boundary between C and C++, a compatible interface header file should be provided.",[19,3297,3224,3298,3301],{},[68,3299,3300],{},"extern \"C\""," in header files only takes effect when processed by the C++ compiler. Its purpose is to tell the C++ compiler: these functions should be handled according to C language linkage rules.",[19,3303,3304,3305,1141],{},"For interfaces that need to be used between C and C++, the following header file template is recommended, and the file extension is suggested to be ",[68,3306,1373],{},[61,3308,3312],{"className":3309,"code":3310,"language":3311,"meta":66,"style":66},"language-c shiki shiki-themes github-light github-dark","#ifndef __FILE_NAME_H_  \u002F\u002F 防止头文件被重复包含，使用时要修改宏名\n#define __FILE_NAME_H_\n\n#ifdef __cplusplus      \u002F\u002F 当前文件被 C++ 编译器处理时才会成立\nextern \"C\" {\n#endif\n\n\u002F* 头文件内容开始 *\u002F\n\n\u002F\u002F 在这里编写必要的预处理指令、类型定义、函数声明和变量声明\n\n\u002F* 头文件内容结束 *\u002F\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif  \u002F\u002F __FILE_NAME_H_\n","c",[68,3313,3314,3322,3332,3336,3347,3358,3363,3367,3371,3375,3379,3383,3387,3391,3398,3402,3406,3410],{"__ignoreMap":66},[71,3315,3316,3318,3320],{"class":73,"line":74},[71,3317,3056],{"class":169},[71,3319,3059],{"class":173},[71,3321,3062],{"class":163},[71,3323,3324,3327,3330],{"class":73,"line":81},[71,3325,3326],{"class":77},"#",[71,3328,3329],{"class":173},"define",[71,3331,3070],{"class":173},[71,3333,3334],{"class":73,"line":87},[71,3335,91],{"emptyLinePlaceholder":90},[71,3337,3338,3341,3344],{"class":73,"line":94},[71,3339,3340],{"class":169},"#ifdef",[71,3342,3343],{"class":173}," __cplusplus",[71,3345,3346],{"class":163},"      \u002F\u002F 当前文件被 C++ 编译器处理时才会成立\n",[71,3348,3349,3352,3355],{"class":73,"line":100},[71,3350,3351],{"class":173},"extern",[71,3353,3354],{"class":404}," \"C\"",[71,3356,3357],{"class":77}," {\n",[71,3359,3360],{"class":73,"line":105},[71,3361,3362],{"class":169},"#endif\n",[71,3364,3365],{"class":73,"line":111},[71,3366,91],{"emptyLinePlaceholder":90},[71,3368,3369],{"class":73,"line":116},[71,3370,3079],{"class":163},[71,3372,3373],{"class":73,"line":336},[71,3374,91],{"emptyLinePlaceholder":90},[71,3376,3377],{"class":73,"line":341},[71,3378,3088],{"class":163},[71,3380,3381],{"class":73,"line":358},[71,3382,91],{"emptyLinePlaceholder":90},[71,3384,3385],{"class":73,"line":372},[71,3386,3097],{"class":163},[71,3388,3389],{"class":73,"line":378},[71,3390,91],{"emptyLinePlaceholder":90},[71,3392,3393,3395],{"class":73,"line":395},[71,3394,3340],{"class":169},[71,3396,3397],{"class":173}," __cplusplus\n",[71,3399,3400],{"class":73,"line":418},[71,3401,119],{"class":77},[71,3403,3404],{"class":73,"line":423},[71,3405,3362],{"class":169},[71,3407,3408],{"class":73,"line":436},[71,3409,91],{"emptyLinePlaceholder":90},[71,3411,3412,3414],{"class":73,"line":448},[71,3413,3106],{"class":169},[71,3415,3109],{"class":163},[19,3417,3418,3419,3421],{},"Here are two examples of independent project forms, both modified from the previously completed ",[68,3420,1421],{}," project. You can choose to practice only one; if practicing consecutively, you need to restore the filenames first according to the instructions in the second example.",[1484,3423,3425,3427,3428],{"id":3424},"maincpp-calls-swapc",[68,3426,1386],{}," calls ",[68,3429,3430],{},"swap.c",[19,3432,3433,3434,3436,3437,3439],{},"This example retains the C++ implementation of ",[68,3435,1386],{}," and changes the ",[68,3438,1421],{}," function to use a C language implementation.",[19,3441,3442,3443,1479,3445,1250],{},"First, rename ",[68,3444,1428],{},[68,3446,3430],{},[19,3448,3449],{},"The main directory structure after modification is:",[61,3451,3454],{"className":3452,"code":3453,"language":515,"meta":66},[513],"src\u002F\n├── CMakeLists.txt\n├── main.cpp\n└── swap\u002F\n    ├── CMakeLists.txt\n    ├── inc\u002Fswap\u002Fswap.h\n    └── src\u002Fswap.c\n",[68,3455,3453],{"__ignoreMap":66},[19,3457,3458],{},[1497,3459],{"alt":1499,"src":3460},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780715114622.webp",[19,3462,3463,3464,3466,3467,1408,3469,3471],{},"Since ",[68,3465,2035],{}," will already collect both the ",[68,3468,3023],{},[68,3470,1380],{}," files, you only need to rename the files here without modifying the CMake file.",[19,3473,3474,3475,3477],{},"Modify ",[68,3476,2881],{}," to make it includable by both C and C++.",[61,3479,3481],{"className":3309,"code":3480,"language":3311,"meta":66,"style":66},"#ifndef __SWAP_H_\n#define __SWAP_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nvoid swap(int a, int b);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif  \u002F\u002F __SWAP_H_\n",[68,3482,3483,3489,3495,3499,3505,3513,3517,3521,3541,3545,3551,3555,3559,3563],{"__ignoreMap":66},[71,3484,3485,3487],{"class":73,"line":74},[71,3486,3056],{"class":169},[71,3488,3148],{"class":173},[71,3490,3491,3493],{"class":73,"line":81},[71,3492,3067],{"class":169},[71,3494,3148],{"class":173},[71,3496,3497],{"class":73,"line":87},[71,3498,91],{"emptyLinePlaceholder":90},[71,3500,3501,3503],{"class":73,"line":94},[71,3502,3340],{"class":169},[71,3504,3397],{"class":173},[71,3506,3507,3509,3511],{"class":73,"line":100},[71,3508,3351],{"class":169},[71,3510,3354],{"class":404},[71,3512,3357],{"class":77},[71,3514,3515],{"class":73,"line":105},[71,3516,3362],{"class":169},[71,3518,3519],{"class":73,"line":111},[71,3520,91],{"emptyLinePlaceholder":90},[71,3522,3523,3525,3527,3529,3531,3533,3535,3537,3539],{"class":73,"line":116},[71,3524,549],{"class":169},[71,3526,552],{"class":173},[71,3528,177],{"class":77},[71,3530,170],{"class":169},[71,3532,953],{"class":182},[71,3534,186],{"class":77},[71,3536,170],{"class":169},[71,3538,1069],{"class":182},[71,3540,1182],{"class":77},[71,3542,3543],{"class":73,"line":336},[71,3544,91],{"emptyLinePlaceholder":90},[71,3546,3547,3549],{"class":73,"line":341},[71,3548,3340],{"class":169},[71,3550,3397],{"class":173},[71,3552,3553],{"class":73,"line":358},[71,3554,119],{"class":77},[71,3556,3557],{"class":73,"line":372},[71,3558,3362],{"class":169},[71,3560,3561],{"class":73,"line":378},[71,3562,91],{"emptyLinePlaceholder":90},[71,3564,3565,3567],{"class":73,"line":395},[71,3566,3106],{"class":169},[71,3568,3210],{"class":163},[19,3570,3571,3572,3574,3575,1141],{},"Note that this header file may be processed by a C compiler, so do not include ",[68,3573,3262],{}," in it or write ",[68,3576,1622],{},[19,3578,3579,3580,3582,3583,1250],{},"Implementing ",[68,3581,1421],{}," in C within ",[68,3584,3585],{},"src\u002Fswap\u002Fsrc\u002Fswap.c",[61,3587,3589],{"className":3309,"code":3588,"language":3311,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n#include \u003Cstdio.h>\n\nvoid swap(int a, int b)\n{\n    int temp = a;\n    a = b;\n    b = temp;\n\n    printf(\"a = %d\\n\", a);\n    printf(\"b = %d\\n\", b);\n}\n",[68,3590,3591,3597,3604,3608,3628,3632,3642,3650,3658,3662,3681,3697],{"__ignoreMap":66},[71,3592,3593,3595],{"class":73,"line":74},[71,3594,1557],{"class":169},[71,3596,1656],{"class":404},[71,3598,3599,3601],{"class":73,"line":81},[71,3600,1557],{"class":169},[71,3602,3603],{"class":404}," \u003Cstdio.h>\n",[71,3605,3606],{"class":73,"line":87},[71,3607,91],{"emptyLinePlaceholder":90},[71,3609,3610,3612,3614,3616,3618,3620,3622,3624,3626],{"class":73,"line":94},[71,3611,549],{"class":169},[71,3613,552],{"class":173},[71,3615,177],{"class":77},[71,3617,170],{"class":169},[71,3619,953],{"class":182},[71,3621,186],{"class":77},[71,3623,170],{"class":169},[71,3625,1069],{"class":182},[71,3627,194],{"class":77},[71,3629,3630],{"class":73,"line":100},[71,3631,84],{"class":77},[71,3633,3634,3636,3638,3640],{"class":73,"line":105},[71,3635,203],{"class":169},[71,3637,629],{"class":77},[71,3639,209],{"class":169},[71,3641,1695],{"class":77},[71,3643,3644,3646,3648],{"class":73,"line":111},[71,3645,426],{"class":77},[71,3647,209],{"class":169},[71,3649,1103],{"class":77},[71,3651,3652,3654,3656],{"class":73,"line":116},[71,3653,439],{"class":77},[71,3655,209],{"class":169},[71,3657,653],{"class":77},[71,3659,3660],{"class":73,"line":336},[71,3661,91],{"emptyLinePlaceholder":90},[71,3663,3664,3667,3669,3672,3675,3678],{"class":73,"line":341},[71,3665,3666],{"class":173},"    printf",[71,3668,177],{"class":77},[71,3670,3671],{"class":404},"\"a = ",[71,3673,3674],{"class":351},"%d\\n",[71,3676,3677],{"class":404},"\"",[71,3679,3680],{"class":77},", a);\n",[71,3682,3683,3685,3687,3690,3692,3694],{"class":73,"line":358},[71,3684,3666],{"class":173},[71,3686,177],{"class":77},[71,3688,3689],{"class":404},"\"b = ",[71,3691,3674],{"class":351},[71,3693,3677],{"class":404},[71,3695,3696],{"class":77},", b);\n",[71,3698,3699],{"class":73,"line":372},[71,3700,119],{"class":77},[19,3702,3703,3705],{},[68,3704,1361],{}," remains a C++ source file and requires no changes:",[61,3707,3709],{"className":63,"code":3708,"language":65,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n\nint main()\n{\n    int a = 100;\n    int b = 200;\n\n    swap(a, b);\n    return 0;\n}\n",[68,3710,3711,3717,3721,3729,3733,3745,3757,3761,3767,3775],{"__ignoreMap":66},[71,3712,3713,3715],{"class":73,"line":74},[71,3714,1557],{"class":169},[71,3716,1656],{"class":404},[71,3718,3719],{"class":73,"line":81},[71,3720,91],{"emptyLinePlaceholder":90},[71,3722,3723,3725,3727],{"class":73,"line":87},[71,3724,170],{"class":169},[71,3726,330],{"class":173},[71,3728,896],{"class":77},[71,3730,3731],{"class":73,"line":94},[71,3732,84],{"class":77},[71,3734,3735,3737,3739,3741,3743],{"class":73,"line":100},[71,3736,203],{"class":169},[71,3738,346],{"class":77},[71,3740,209],{"class":169},[71,3742,431],{"class":351},[71,3744,355],{"class":77},[71,3746,3747,3749,3751,3753,3755],{"class":73,"line":105},[71,3748,203],{"class":169},[71,3750,363],{"class":77},[71,3752,209],{"class":169},[71,3754,1295],{"class":351},[71,3756,355],{"class":77},[71,3758,3759],{"class":73,"line":111},[71,3760,91],{"emptyLinePlaceholder":90},[71,3762,3763,3765],{"class":73,"line":116},[71,3764,765],{"class":173},[71,3766,463],{"class":77},[71,3768,3769,3771,3773],{"class":73,"line":336},[71,3770,223],{"class":169},[71,3772,498],{"class":351},[71,3774,355],{"class":77},[71,3776,3777],{"class":73,"line":341},[71,3778,119],{"class":77},[19,3780,3781],{},[22,3782,1874,3783,1877],{},[68,3784,3430],{},[61,3786,3788],{"className":3787,"code":1881,"language":515,"meta":66},[513],[68,3789,1881],{"__ignoreMap":66},[19,3791,3792],{},[1497,3793],{"alt":1499,"src":3794},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780715202883.webp",[19,3796,3797,3798,3800,3801,3804,3805,3807,3808,3810,3811,3813,3814,3816,3817,1141],{},"When compiling ",[68,3799,3430],{},", the C compiler does not define ",[68,3802,3803],{},"__cplusplus",", thus skipping ",[68,3806,3300],{},". When compiling ",[68,3809,1386],{},", the C++ compiler will see ",[68,3812,3300],{},", and therefore, following C language linkage rules, it will look for the ",[68,3815,1421],{}," function in ",[68,3818,3430],{},[1484,3820,3822,3427,3824],{"id":3821},"mainc-calls-swapcpp",[68,3823,3288],{},[68,3825,1428],{},[519,3827,3828],{},[19,3829,3830],{},"Challenging aspects commonly encountered in STM32 HAL library,",[19,3832,3833,3834,3836],{},"This example flips the case: the entry file uses C language, while the ",[68,3835,1421],{}," library continues to be implemented in C++.",[19,3838,3839,3840,3842,3843,1250],{},"If you just finished the last example, first change ",[68,3841,3430],{}," back to ",[68,3844,1428],{},[19,3846,3847,3848,1479,3850,1250],{},"Next, rename the entry file ",[68,3849,1386],{},[68,3851,3288],{},[19,3853,3854],{},[1497,3855],{"alt":1499,"src":3856},"https:\u002F\u002Fcdn.tungchiahui.cn\u002Ftungwebsite\u002Fassets\u002Fimages\u002F2023\u002F10\u002F05\u002F1780715304838.webp",[19,3858,3449],{},[61,3860,3863],{"className":3861,"code":3862,"language":515,"meta":66},[513],"src\u002F\n├── CMakeLists.txt\n├── main.c\n└── swap\u002F\n    ├── CMakeLists.txt\n    ├── inc\u002Fswap\u002Fswap.h\n    └── src\u002Fswap.cpp\n",[68,3864,3862],{"__ignoreMap":66},[19,3866,3867,3868,3870],{},"After the file name changes, you still need to open ",[68,3869,2604],{}," and...",[61,3872,3874],{"className":1923,"code":3873,"language":1925,"meta":66,"style":66},"add_executable(${PROJECT_NAME}\n  ${CMAKE_CURRENT_SOURCE_DIR}\u002Fmain.cpp\n)\n",[68,3875,3876,3884,3890],{"__ignoreMap":66},[71,3877,3878,3880,3882],{"class":73,"line":74},[71,3879,2614],{"class":169},[71,3881,177],{"class":77},[71,3883,2551],{"class":169},[71,3885,3886,3888],{"class":73,"line":81},[71,3887,2623],{"class":169},[71,3889,2626],{"class":77},[71,3891,3892],{"class":73,"line":87},[71,3893,194],{"class":77},[19,3895,1945],{},[61,3897,3899],{"className":1923,"code":3898,"language":1925,"meta":66,"style":66},"add_executable(${PROJECT_NAME}\n  ${CMAKE_CURRENT_SOURCE_DIR}\u002Fmain.c\n)\n",[68,3900,3901,3909,3916],{"__ignoreMap":66},[71,3902,3903,3905,3907],{"class":73,"line":74},[71,3904,2614],{"class":169},[71,3906,177],{"class":77},[71,3908,2551],{"class":169},[71,3910,3911,3913],{"class":73,"line":81},[71,3912,2623],{"class":169},[71,3914,3915],{"class":77},"\u002Fmain.c\n",[71,3917,3918],{"class":73,"line":87},[71,3919,194],{"class":77},[19,3921,3922,3924],{},[68,3923,2881],{}," Continue using the compatible approach from earlier:",[61,3926,3927],{"className":3309,"code":3480,"language":3311,"meta":66,"style":66},[68,3928,3929,3935,3941,3945,3951,3959,3963,3967,3987,3991,3997,4001,4005,4009],{"__ignoreMap":66},[71,3930,3931,3933],{"class":73,"line":74},[71,3932,3056],{"class":169},[71,3934,3148],{"class":173},[71,3936,3937,3939],{"class":73,"line":81},[71,3938,3067],{"class":169},[71,3940,3148],{"class":173},[71,3942,3943],{"class":73,"line":87},[71,3944,91],{"emptyLinePlaceholder":90},[71,3946,3947,3949],{"class":73,"line":94},[71,3948,3340],{"class":169},[71,3950,3397],{"class":173},[71,3952,3953,3955,3957],{"class":73,"line":100},[71,3954,3351],{"class":169},[71,3956,3354],{"class":404},[71,3958,3357],{"class":77},[71,3960,3961],{"class":73,"line":105},[71,3962,3362],{"class":169},[71,3964,3965],{"class":73,"line":111},[71,3966,91],{"emptyLinePlaceholder":90},[71,3968,3969,3971,3973,3975,3977,3979,3981,3983,3985],{"class":73,"line":116},[71,3970,549],{"class":169},[71,3972,552],{"class":173},[71,3974,177],{"class":77},[71,3976,170],{"class":169},[71,3978,953],{"class":182},[71,3980,186],{"class":77},[71,3982,170],{"class":169},[71,3984,1069],{"class":182},[71,3986,1182],{"class":77},[71,3988,3989],{"class":73,"line":336},[71,3990,91],{"emptyLinePlaceholder":90},[71,3992,3993,3995],{"class":73,"line":341},[71,3994,3340],{"class":169},[71,3996,3397],{"class":173},[71,3998,3999],{"class":73,"line":358},[71,4000,119],{"class":77},[71,4002,4003],{"class":73,"line":372},[71,4004,3362],{"class":169},[71,4006,4007],{"class":73,"line":378},[71,4008,91],{"emptyLinePlaceholder":90},[71,4010,4011,4013],{"class":73,"line":395},[71,4012,3106],{"class":169},[71,4014,3210],{"class":163},[19,4016,4017,4018,4020,4021,1250],{},"Use C++ to implement ",[68,4019,1421],{}," within ",[68,4022,2894],{},[61,4024,4026],{"className":63,"code":4025,"language":65,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n#include \u003Ciostream>\n\nvoid swap(int a, int b)\n{\n    int temp = a;\n    a = b;\n    b = temp;\n\n    std::cout \u003C\u003C \"a = \" \u003C\u003C a \u003C\u003C std::endl;\n    std::cout \u003C\u003C \"b = \" \u003C\u003C b \u003C\u003C std::endl;\n}\n",[68,4027,4028,4034,4040,4044,4064,4068,4078,4086,4094,4098,4121,4141],{"__ignoreMap":66},[71,4029,4030,4032],{"class":73,"line":74},[71,4031,1557],{"class":169},[71,4033,1656],{"class":404},[71,4035,4036,4038],{"class":73,"line":81},[71,4037,1557],{"class":169},[71,4039,3165],{"class":404},[71,4041,4042],{"class":73,"line":87},[71,4043,91],{"emptyLinePlaceholder":90},[71,4045,4046,4048,4050,4052,4054,4056,4058,4060,4062],{"class":73,"line":94},[71,4047,549],{"class":169},[71,4049,552],{"class":173},[71,4051,177],{"class":77},[71,4053,170],{"class":169},[71,4055,953],{"class":182},[71,4057,186],{"class":77},[71,4059,170],{"class":169},[71,4061,1069],{"class":182},[71,4063,194],{"class":77},[71,4065,4066],{"class":73,"line":100},[71,4067,84],{"class":77},[71,4069,4070,4072,4074,4076],{"class":73,"line":105},[71,4071,203],{"class":169},[71,4073,629],{"class":77},[71,4075,209],{"class":169},[71,4077,1695],{"class":77},[71,4079,4080,4082,4084],{"class":73,"line":111},[71,4081,426],{"class":77},[71,4083,209],{"class":169},[71,4085,1103],{"class":77},[71,4087,4088,4090,4092],{"class":73,"line":116},[71,4089,439],{"class":77},[71,4091,209],{"class":169},[71,4093,653],{"class":77},[71,4095,4096],{"class":73,"line":336},[71,4097,91],{"emptyLinePlaceholder":90},[71,4099,4100,4103,4106,4108,4110,4112,4114,4116,4118],{"class":73,"line":341},[71,4101,4102],{"class":173},"    std",[71,4104,4105],{"class":77},"::cout ",[71,4107,401],{"class":169},[71,4109,981],{"class":404},[71,4111,408],{"class":169},[71,4113,346],{"class":77},[71,4115,401],{"class":169},[71,4117,1571],{"class":173},[71,4119,4120],{"class":77},"::endl;\n",[71,4122,4123,4125,4127,4129,4131,4133,4135,4137,4139],{"class":73,"line":358},[71,4124,4102],{"class":173},[71,4126,4105],{"class":77},[71,4128,401],{"class":169},[71,4130,1740],{"class":404},[71,4132,408],{"class":169},[71,4134,363],{"class":77},[71,4136,401],{"class":169},[71,4138,1571],{"class":173},[71,4140,4120],{"class":77},[71,4142,4143],{"class":73,"line":372},[71,4144,119],{"class":77},[19,4146,4147,4149,4150,4152,4153,4155],{},[68,4148,1428],{}," must contain ",[68,4151,1425],{},". After reading the header file, the C++ compiler will recognize that this ",[68,4154,1421],{}," function needs to be exposed externally according to C language linkage rules.",[19,4157,4158,4159,4162,4163,4165,4166,4168],{},"Finally, call it within ",[68,4160,4161],{},"src\u002Fmain.c",", and ",[68,4164,3288],{}," still follows ",[68,4167,1386],{}," without any modifications:",[61,4170,4172],{"className":3309,"code":4171,"language":3311,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n\nint main(void)\n{\n    int a = 100;\n    int b = 200;\n\n    swap(a, b);\n    return 0;\n}\n",[68,4173,4174,4180,4184,4196,4200,4212,4224,4228,4234,4242],{"__ignoreMap":66},[71,4175,4176,4178],{"class":73,"line":74},[71,4177,1557],{"class":169},[71,4179,1656],{"class":404},[71,4181,4182],{"class":73,"line":81},[71,4183,91],{"emptyLinePlaceholder":90},[71,4185,4186,4188,4190,4192,4194],{"class":73,"line":87},[71,4187,170],{"class":169},[71,4189,330],{"class":173},[71,4191,177],{"class":77},[71,4193,549],{"class":169},[71,4195,194],{"class":77},[71,4197,4198],{"class":73,"line":94},[71,4199,84],{"class":77},[71,4201,4202,4204,4206,4208,4210],{"class":73,"line":100},[71,4203,203],{"class":169},[71,4205,346],{"class":77},[71,4207,209],{"class":169},[71,4209,431],{"class":351},[71,4211,355],{"class":77},[71,4213,4214,4216,4218,4220,4222],{"class":73,"line":105},[71,4215,203],{"class":169},[71,4217,363],{"class":77},[71,4219,209],{"class":169},[71,4221,1295],{"class":351},[71,4223,355],{"class":77},[71,4225,4226],{"class":73,"line":111},[71,4227,91],{"emptyLinePlaceholder":90},[71,4229,4230,4232],{"class":73,"line":116},[71,4231,765],{"class":173},[71,4233,463],{"class":77},[71,4235,4236,4238,4240],{"class":73,"line":336},[71,4237,223],{"class":169},[71,4239,498],{"class":351},[71,4241,355],{"class":77},[71,4243,4244],{"class":73,"line":341},[71,4245,119],{"class":77},[19,4247,4248,4249,4251,4252,4255,4256,1141],{},"Only the header file is used to call ",[68,4250,1421],{},", and there's no need to understand advanced C++ syntax like ",[68,4253,4254],{},"std::cout",". All C++ code remains within ",[68,4257,1428],{},[19,4259,4260,4261,4263],{},"Only functions that need to cross the C\u002FC++ boundary require this compatible implementation. Other ",[68,4262,1380],{}," files still follow regular C++ calling conventions among themselves.",[19,4265,4266,4267,4270,4271,4274,4275,4277,4278,4280,4281,4283,4284,4286],{},"The top-level ",[68,4268,4269],{},"CMakeLists.txt"," of the template has enabled C and C++ via ",[68,4272,4273],{},"LANGUAGES C CXX",". CMake will use the C compiler to compile ",[68,4276,3288],{},", the C++ compiler to compile ",[68,4279,1428],{},", and build ",[68,4282,1428],{}," into the ",[68,4285,2798],{}," shared library within the template, before linking it to the main program.",[19,4288,4289,4291],{},[68,4290,3300],{}," only changes the linkage rules, and does not automatically convert C++ code to C. Interfaces placed within it should use types and syntax that C can understand, avoiding C++-specific features such as function overloading, classes, templates, or C++ references.",[1484,4293,4295,3427,4297,4299],{"id":4294},"mainc-calls-swapcppadvanced",[68,4296,3288],{},[68,4298,1428],{},"(advanced)",[519,4301,4302],{},[19,4303,3830],{},[19,4305,4306,4307,4309,4310,4312],{},"The previous example directly converted the ",[68,4308,1421],{}," function into a C interface. While this can work, it also introduces a limitation: ",[68,4311,1425],{}," must be comprehensible to the C compiler, so it cannot use C++-specific constructs such as namespaces, classes, templates, function overloading, or C++ references.",[19,4314,4315,4316,1250],{},"A more commonly used approach is to add an additional ",[22,4317,4318],{},"C interface layer",[37,4320,4321,4329,4335],{},[40,4322,4323,4325,4326,1141],{},[68,4324,3288],{}," Only call a function that C can understand, such as ",[68,4327,4328],{},"cpp_main()",[40,4330,4331,4334],{},[68,4332,4333],{},"cpp_interface.cpp"," is responsible for entering the world of C++.",[40,4336,4337,4339],{},[68,4338,1428],{}," Keep the regular C++ style; you can use namespaces.",[19,4341,3449],{},[61,4343,4346],{"className":4344,"code":4345,"language":515,"meta":66},[513],"src\u002F\n├── CMakeLists.txt\n├── cpp_interface.cpp\n├── cpp_interface.h\n├── main.c\n└── swap\u002F\n    ├── CMakeLists.txt\n    ├── inc\u002Fswap\u002Fswap.h\n    └── src\u002Fswap.cpp\n",[68,4347,4345],{"__ignoreMap":66},[19,4349,4350,4351,4353,4354,1250],{},"First, under ",[68,4352,2441],{},", create ",[68,4355,4356],{},"cpp_interface.h",[61,4358,4360],{"className":3309,"code":4359,"language":3311,"meta":66,"style":66},"#ifndef __CPP_INTERFACE_H_\n#define __CPP_INTERFACE_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nint cpp_main(void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif  \u002F\u002F __CPP_INTERFACE_H_\n",[68,4361,4362,4369,4375,4379,4385,4393,4397,4401,4414,4418,4424,4428,4432,4436],{"__ignoreMap":66},[71,4363,4364,4366],{"class":73,"line":74},[71,4365,3056],{"class":169},[71,4367,4368],{"class":173}," __CPP_INTERFACE_H_\n",[71,4370,4371,4373],{"class":73,"line":81},[71,4372,3067],{"class":169},[71,4374,4368],{"class":173},[71,4376,4377],{"class":73,"line":87},[71,4378,91],{"emptyLinePlaceholder":90},[71,4380,4381,4383],{"class":73,"line":94},[71,4382,3340],{"class":169},[71,4384,3397],{"class":173},[71,4386,4387,4389,4391],{"class":73,"line":100},[71,4388,3351],{"class":169},[71,4390,3354],{"class":404},[71,4392,3357],{"class":77},[71,4394,4395],{"class":73,"line":105},[71,4396,3362],{"class":169},[71,4398,4399],{"class":73,"line":111},[71,4400,91],{"emptyLinePlaceholder":90},[71,4402,4403,4405,4408,4410,4412],{"class":73,"line":116},[71,4404,170],{"class":169},[71,4406,4407],{"class":173}," cpp_main",[71,4409,177],{"class":77},[71,4411,549],{"class":169},[71,4413,1182],{"class":77},[71,4415,4416],{"class":73,"line":336},[71,4417,91],{"emptyLinePlaceholder":90},[71,4419,4420,4422],{"class":73,"line":341},[71,4421,3340],{"class":169},[71,4423,3397],{"class":173},[71,4425,4426],{"class":73,"line":358},[71,4427,119],{"class":77},[71,4429,4430],{"class":73,"line":372},[71,4431,3362],{"class":169},[71,4433,4434],{"class":73,"line":378},[71,4435,91],{"emptyLinePlaceholder":90},[71,4437,4438,4440],{"class":73,"line":395},[71,4439,3106],{"class":169},[71,4441,4442],{"class":163},"  \u002F\u002F __CPP_INTERFACE_H_\n",[19,4444,4445,4446,4448,4449,4452],{},"This header file is the C interface truly meant for ",[68,4447,3288],{},". It only declares ",[68,4450,4451],{},"cpp_main(void)"," with parameters and return values using types that C can understand.",[19,4454,4455,4456,1250],{},"Then modify ",[68,4457,4161],{},[61,4459,4461],{"className":3309,"code":4460,"language":3311,"meta":66,"style":66},"#include \"cpp_interface.h\"\n\nint main(void)\n{\n    return cpp_main();\n}\n",[68,4462,4463,4470,4474,4486,4490,4499],{"__ignoreMap":66},[71,4464,4465,4467],{"class":73,"line":74},[71,4466,1557],{"class":169},[71,4468,4469],{"class":404}," \"cpp_interface.h\"\n",[71,4471,4472],{"class":73,"line":81},[71,4473,91],{"emptyLinePlaceholder":90},[71,4475,4476,4478,4480,4482,4484],{"class":73,"line":87},[71,4477,170],{"class":169},[71,4479,330],{"class":173},[71,4481,177],{"class":77},[71,4483,549],{"class":169},[71,4485,194],{"class":77},[71,4487,4488],{"class":73,"line":94},[71,4489,84],{"class":77},[71,4491,4492,4494,4496],{"class":73,"line":100},[71,4493,223],{"class":169},[71,4495,4407],{"class":173},[71,4497,4498],{"class":77},"();\n",[71,4500,4501],{"class":73,"line":105},[71,4502,119],{"class":77},[19,4504,4505,4506,4508,4509,4511,4512,4514,4515,1141],{},"At this point, ",[68,4507,3288],{}," no longer contains ",[68,4510,2427],{}," and no longer directly calls ",[68,4513,1421],{},". It is only responsible for launching the C++ side ",[68,4516,4328],{},[19,4518,4519,4520,4522,4523,1250],{},"Now let's change ",[68,4521,2881],{}," back to a regular C++ header file and add a namespace to ",[68,4524,1421],{},[61,4526,4528],{"className":63,"code":4527,"language":65,"meta":66,"style":66},"#ifndef __SWAP_H_\n#define __SWAP_H_\n\nnamespace swap_demo\n{\nvoid swap(int a, int b);\n}\n\n#endif  \u002F\u002F __SWAP_H_\n",[68,4529,4530,4536,4542,4546,4554,4558,4578,4582,4586],{"__ignoreMap":66},[71,4531,4532,4534],{"class":73,"line":74},[71,4533,3056],{"class":169},[71,4535,3148],{"class":173},[71,4537,4538,4540],{"class":73,"line":81},[71,4539,3067],{"class":169},[71,4541,3148],{"class":173},[71,4543,4544],{"class":73,"line":87},[71,4545,91],{"emptyLinePlaceholder":90},[71,4547,4548,4551],{"class":73,"line":94},[71,4549,4550],{"class":169},"namespace",[71,4552,4553],{"class":173}," swap_demo\n",[71,4555,4556],{"class":73,"line":100},[71,4557,84],{"class":77},[71,4559,4560,4562,4564,4566,4568,4570,4572,4574,4576],{"class":73,"line":105},[71,4561,549],{"class":169},[71,4563,552],{"class":173},[71,4565,177],{"class":77},[71,4567,170],{"class":169},[71,4569,953],{"class":182},[71,4571,186],{"class":77},[71,4573,170],{"class":169},[71,4575,1069],{"class":182},[71,4577,1182],{"class":77},[71,4579,4580],{"class":73,"line":111},[71,4581,119],{"class":77},[71,4583,4584],{"class":73,"line":116},[71,4585,91],{"emptyLinePlaceholder":90},[71,4587,4588,4590],{"class":73,"line":336},[71,4589,3106],{"class":169},[71,4591,3210],{"class":163},[19,4593,4594,4595,4597,4598,4600,4601,4603],{},"Note, this ",[68,4596,1425],{}," is no longer a C header file. It contains ",[68,4599,4550],{},", so it can't be directly included by ",[68,4602,3288],{}," anymore.",[19,4605,4606,4607,1250],{},"Here doesn't need to be added to ",[68,4608,1425],{},[61,4610,4612],{"className":63,"code":4611,"language":65,"meta":66,"style":66},"#ifdef __cplusplus\nextern \"C\" {\n#endif\n",[68,4613,4614,4620,4628],{"__ignoreMap":66},[71,4615,4616,4618],{"class":73,"line":74},[71,4617,3340],{"class":169},[71,4619,3397],{"class":173},[71,4621,4622,4624,4626],{"class":73,"line":81},[71,4623,3351],{"class":169},[71,4625,3354],{"class":404},[71,4627,3357],{"class":77},[71,4629,4630],{"class":73,"line":87},[71,4631,3362],{"class":169},[19,4633,4634,4635,4638,4639,4641,4642,4644,4645,1141],{},"The reason is: ",[68,4636,4637],{},"swap_demo::swap"," is just an ordinary C++ function, and we want it to retain the C++ namespace convention. ",[68,4640,3300],{}," should only be placed on the interface layer that C code actually calls, which is the ",[68,4643,4451],{}," in the previously mentioned ",[68,4646,4356],{},[19,4648,4649],{},"In other words, the advanced version contains two header files:",[2856,4651,4652,4668],{},[2859,4653,4654],{},[2862,4655,4656,4659,4662],{},[2865,4657,4658],{"align":2867},"Header file",[2865,4660,4661],{"align":2867},"Who will include",[2865,4663,4664,4665,4667],{"align":2867},"Whether ",[68,4666,3300],{}," is needed.",[2872,4669,4670,4685],{},[2862,4671,4672,4676,4682],{},[2877,4673,4674],{"align":2867},[68,4675,4356],{},[2877,4677,4678,1408,4680],{"align":2867},[68,4679,3288],{},[68,4681,4333],{},[2877,4683,4684],{"align":2867},"Needed because it's a C\u002FC++ boundary.",[2862,4686,4687,4691,4697],{},[2877,4688,4689],{"align":2867},[68,4690,2427],{},[2877,4692,4693,1408,4695],{"align":2867},[68,4694,1428],{},[68,4696,4333],{},[2877,4698,4699],{"align":2867},"不需要，因为它是纯C++头文件",[19,4701,4702,4703,1250],{},"Continue modifying ",[68,4704,2894],{},[61,4706,4708],{"className":63,"code":4707,"language":65,"meta":66,"style":66},"#include \"swap\u002Fswap.h\"\n#include \u003Ciostream>\n\nnamespace swap_demo\n{\nvoid swap(int a, int b)\n{\n    int temp = a;\n    a = b;\n    b = temp;\n\n    std::cout \u003C\u003C \"a = \" \u003C\u003C a \u003C\u003C std::endl;\n    std::cout \u003C\u003C \"b = \" \u003C\u003C b \u003C\u003C std::endl;\n}\n}\n",[68,4709,4710,4716,4722,4726,4732,4736,4756,4760,4770,4778,4786,4790,4810,4830,4834],{"__ignoreMap":66},[71,4711,4712,4714],{"class":73,"line":74},[71,4713,1557],{"class":169},[71,4715,1656],{"class":404},[71,4717,4718,4720],{"class":73,"line":81},[71,4719,1557],{"class":169},[71,4721,3165],{"class":404},[71,4723,4724],{"class":73,"line":87},[71,4725,91],{"emptyLinePlaceholder":90},[71,4727,4728,4730],{"class":73,"line":94},[71,4729,4550],{"class":169},[71,4731,4553],{"class":173},[71,4733,4734],{"class":73,"line":100},[71,4735,84],{"class":77},[71,4737,4738,4740,4742,4744,4746,4748,4750,4752,4754],{"class":73,"line":105},[71,4739,549],{"class":169},[71,4741,552],{"class":173},[71,4743,177],{"class":77},[71,4745,170],{"class":169},[71,4747,953],{"class":182},[71,4749,186],{"class":77},[71,4751,170],{"class":169},[71,4753,1069],{"class":182},[71,4755,194],{"class":77},[71,4757,4758],{"class":73,"line":111},[71,4759,84],{"class":77},[71,4761,4762,4764,4766,4768],{"class":73,"line":116},[71,4763,203],{"class":169},[71,4765,629],{"class":77},[71,4767,209],{"class":169},[71,4769,1695],{"class":77},[71,4771,4772,4774,4776],{"class":73,"line":336},[71,4773,426],{"class":77},[71,4775,209],{"class":169},[71,4777,1103],{"class":77},[71,4779,4780,4782,4784],{"class":73,"line":341},[71,4781,439],{"class":77},[71,4783,209],{"class":169},[71,4785,653],{"class":77},[71,4787,4788],{"class":73,"line":358},[71,4789,91],{"emptyLinePlaceholder":90},[71,4791,4792,4794,4796,4798,4800,4802,4804,4806,4808],{"class":73,"line":372},[71,4793,4102],{"class":173},[71,4795,4105],{"class":77},[71,4797,401],{"class":169},[71,4799,981],{"class":404},[71,4801,408],{"class":169},[71,4803,346],{"class":77},[71,4805,401],{"class":169},[71,4807,1571],{"class":173},[71,4809,4120],{"class":77},[71,4811,4812,4814,4816,4818,4820,4822,4824,4826,4828],{"class":73,"line":378},[71,4813,4102],{"class":173},[71,4815,4105],{"class":77},[71,4817,401],{"class":169},[71,4819,1740],{"class":404},[71,4821,408],{"class":169},[71,4823,363],{"class":77},[71,4825,401],{"class":169},[71,4827,1571],{"class":173},[71,4829,4120],{"class":77},[71,4831,4832],{"class":73,"line":395},[71,4833,119],{"class":77},[71,4835,4836],{"class":73,"line":418},[71,4837,119],{"class":77},[19,4839,4840,4841,1250],{},"Finally, create ",[68,4842,4843],{},"src\u002Fcpp_interface.cpp",[61,4845,4847],{"className":63,"code":4846,"language":65,"meta":66,"style":66},"#include \"cpp_interface.h\"\n#include \"swap\u002Fswap.h\"\n\nint cpp_main(void)\n{\n    int a = 100;\n    int b = 200;\n\n    swap_demo::swap(a, b);\n\n    return 0;\n}\n",[68,4848,4849,4855,4861,4865,4877,4881,4893,4905,4909,4921,4925,4933],{"__ignoreMap":66},[71,4850,4851,4853],{"class":73,"line":74},[71,4852,1557],{"class":169},[71,4854,4469],{"class":404},[71,4856,4857,4859],{"class":73,"line":81},[71,4858,1557],{"class":169},[71,4860,1656],{"class":404},[71,4862,4863],{"class":73,"line":87},[71,4864,91],{"emptyLinePlaceholder":90},[71,4866,4867,4869,4871,4873,4875],{"class":73,"line":94},[71,4868,170],{"class":169},[71,4870,4407],{"class":173},[71,4872,177],{"class":77},[71,4874,549],{"class":169},[71,4876,194],{"class":77},[71,4878,4879],{"class":73,"line":100},[71,4880,84],{"class":77},[71,4882,4883,4885,4887,4889,4891],{"class":73,"line":105},[71,4884,203],{"class":169},[71,4886,346],{"class":77},[71,4888,209],{"class":169},[71,4890,431],{"class":351},[71,4892,355],{"class":77},[71,4894,4895,4897,4899,4901,4903],{"class":73,"line":111},[71,4896,203],{"class":169},[71,4898,363],{"class":77},[71,4900,209],{"class":169},[71,4902,1295],{"class":351},[71,4904,355],{"class":77},[71,4906,4907],{"class":73,"line":116},[71,4908,91],{"emptyLinePlaceholder":90},[71,4910,4911,4914,4917,4919],{"class":73,"line":336},[71,4912,4913],{"class":173},"    swap_demo",[71,4915,4916],{"class":77},"::",[71,4918,1421],{"class":173},[71,4920,463],{"class":77},[71,4922,4923],{"class":73,"line":341},[71,4924,91],{"emptyLinePlaceholder":90},[71,4926,4927,4929,4931],{"class":73,"line":358},[71,4928,223],{"class":169},[71,4930,498],{"class":351},[71,4932,355],{"class":77},[71,4934,4935],{"class":73,"line":372},[71,4936,119],{"class":77},[19,4938,4939,4941,4942,2347,4944,4946,4947,4949,4950,1141],{},[68,4940,4333],{}," serves as the interface between C and C++. It includes ",[68,4943,4356],{},[68,4945,4328],{}," will be exposed using C language linkage rules. It is itself a ",[68,4948,1380],{}," file, allowing internal calls to C++ constructs like ",[68,4951,4952],{},"swap_demo::swap(a, b)",[19,4954,4955,4956,4958,4959,4961],{},"After adding the file, you still need to open ",[68,4957,2604],{}," and include ",[68,4960,4333],{}," in the main program:",[61,4963,4965],{"className":1923,"code":4964,"language":1925,"meta":66,"style":66},"add_executable(${PROJECT_NAME}\n  ${CMAKE_CURRENT_SOURCE_DIR}\u002Fmain.c\n  ${CMAKE_CURRENT_SOURCE_DIR}\u002Fcpp_interface.cpp\n)\n",[68,4966,4967,4975,4981,4988],{"__ignoreMap":66},[71,4968,4969,4971,4973],{"class":73,"line":74},[71,4970,2614],{"class":169},[71,4972,177],{"class":77},[71,4974,2551],{"class":169},[71,4976,4977,4979],{"class":73,"line":81},[71,4978,2623],{"class":169},[71,4980,3915],{"class":77},[71,4982,4983,4985],{"class":73,"line":87},[71,4984,2623],{"class":169},[71,4986,4987],{"class":77},"\u002Fcpp_interface.cpp\n",[71,4989,4990],{"class":73,"line":94},[71,4991,194],{"class":77},[19,4993,4994,4995,2909,4997,5000,5001,186,5003,5005],{},"Here, you don't need to put ",[68,4996,4356],{},[68,4998,4999],{},"add_executable()",". CMake is mainly responsible for handing source files like ",[68,5002,3023],{},[68,5004,1380],{},", etc., to the compiler for compilation; header files themselves won't be compiled into an object file separately.",[19,5007,5008,5010,5011,1250],{},[68,5009,4356],{}," is found in the code through ",[68,5012,1557],{},[61,5014,5016],{"className":3309,"code":5015,"language":3311,"meta":66,"style":66},"#include \"cpp_interface.h\"\n",[68,5017,5018],{"__ignoreMap":66},[71,5019,5020,5022],{"class":73,"line":74},[71,5021,1557],{"class":169},[71,5023,4469],{"class":404},[19,5025,5026,5027,186,5029,4162,5031,5033,5034,5036],{},"Because ",[68,5028,3288],{},[68,5030,4333],{},[68,5032,4356],{}," are all in the same directory as ",[68,5035,2441],{},", when they are enclosed in double quotes here, the compiler can locate them from the directory of the current source file.",[19,5038,5039,5040,5042,5043,5045,5046,5049],{},"If you move ",[68,5041,4356],{}," into a separate ",[68,5044,2423],{}," directory in the future, you would need to use ",[68,5047,5048],{},"target_include_directories()"," again to add that directory to the header file search path. In the current example, everything is in the same directory level, so no additional CMake modifications are needed.",[19,5051,5052,5054,5055,5057,5058,5060,5061,5063,5064,1141],{},[68,5053,2035],{}," does not need to be modified, as it already collects the ",[68,5056,1380],{}," files from the ",[68,5059,2346],{}," directory, and ",[68,5062,1428],{}," will still be compiled into ",[68,5065,2798],{},[19,5067,5068],{},"After compiling and running, the output still resembles:",[61,5070,5072],{"className":5071,"code":1881,"language":515,"meta":66},[513],[68,5073,1881],{"__ignoreMap":66},[19,5075,5076,5077,5079,5080,5082,5083,5085,5086,5088,5089,1141],{},"The focus of this advanced approach is: ",[68,5078,3300],{}," is only placed on the outermost, simplest interface, which is ",[68,5081,4451],{},". The actual C++ code goes behind ",[68,5084,4333],{},", where ",[68,5087,1421],{}," can use namespaces, and future C++ features like classes, templates, and function overloading can also be used—provided these C++-specific elements are not directly exposed to ",[68,5090,3288],{},[14,5092,5094,1408,5097],{"id":5093},"include-and-include",[68,5095,5096],{},"#include \u003C...>",[68,5098,5099],{},"#include \"...\"",[19,5101,5102],{},"Both methods are used for including header files, but they are commonly used in different scenarios:",[61,5104,5106],{"className":63,"code":5105,"language":65,"meta":66,"style":66},"#include \u003Ciostream>\n#include \u003Copencv2\u002Fopencv.hpp>\n",[68,5107,5108,5114],{"__ignoreMap":66},[71,5109,5110,5112],{"class":73,"line":74},[71,5111,1557],{"class":169},[71,5113,3165],{"class":404},[71,5115,5116,5118],{"class":73,"line":81},[71,5117,1557],{"class":169},[71,5119,5120],{"class":404}," \u003Copencv2\u002Fopencv.hpp>\n",[19,5122,5123],{},"Angle brackets are typically used for standard library or already installed third-party library headers.",[61,5125,5126],{"className":63,"code":2402,"language":65,"meta":66,"style":66},[68,5127,5128],{"__ignoreMap":66},[71,5129,5130,5132],{"class":73,"line":74},[71,5131,1557],{"class":169},[71,5133,1656],{"class":404},[19,5135,5136,5137,5140,5141,5143],{},"Double quotes are usually used for header files in the current project. This can be written as ",[68,5138,5139],{},"\"swap\u002Fswap.h\""," because CMake has already added ",[68,5142,2398],{}," to the compiler's header file search path.",[19,5145,5146,5147,5149],{},"Whether using C or C++, header files should be equipped with protection macros; only when a header file serves as an interface between C and C++ should the ",[68,5148,3300],{}," compatibility section be added within the protection macro.",[5151,5152,5153],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}",{"title":66,"searchDepth":81,"depth":81,"links":5155},[5156,5165],{"id":12,"depth":81,"text":12,"children":5157},[5158,5159,5160,5161,5162,5163,5164],{"id":16,"depth":87,"text":17},{"id":31,"depth":87,"text":32},{"id":239,"depth":87,"text":240},{"id":526,"depth":87,"text":527},{"id":849,"depth":87,"text":850},{"id":1122,"depth":87,"text":1123},{"id":1349,"depth":87,"text":1350},{"id":2987,"depth":81,"text":2988,"children":5166},[5167,5168,5169],{"id":3030,"depth":87,"text":3031},{"id":3269,"depth":87,"text":3270},{"id":5093,"depth":87,"text":5170},"#include \u003C...> and #include \"...\"","\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian",0,"0800","2023-10-05","wiki\u002F2023-10-05-cplusplus-jiao-xue","en-us:2023-10-05-cplusplus-jiao-xue","\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue","Cplusplus教学","md","wiki\u002F2023-10-05-Cplusplus教学\u002F0800-函数与头文件",false,null,"en-US","en-us",{},{"title":5,"description":66},"\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0800-函数与头文件","YNsAfX7K5oH4nQUg7hrnVqGXL9QGNg9nTNaKyuqnJ4M",[5191,5196,5201,5206,5211,5216,5221,5226,5227,5232,5237,5242,5247,5252,5257,5262,5267,5272,5277,5282,5287,5292,5297,5302,5307,5312,5317,5322,5327,5332,5337,5342,5347,5352,5357,5362,5367,5372,5377,5382,5386,5391,5396,5401,5406,5411,5416,5421,5426,5431,5436,5441,5446,5451,5456,5461,5466,5471,5476,5481,5486,5491,5496,5501,5506,5511,5516,5521,5526,5531,5536,5541,5546,5551,5556,5561,5566,5571,5576,5581,5586,5591],{"path":5192,"stem":5193,"title":5194,"date":5174,"chapterOrder":5195,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0100-c-kai-fa-huan-jing-da-jian-yu-ce-shi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0100-C++开发环境搭建与测试","C++ Development Environment Setup and Testing","0100",{"path":5197,"stem":5198,"title":5199,"date":5174,"chapterOrder":5200,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0200-c-ji-chu-chu-shi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0200-C++基础初识","C++ Basics","0200",{"path":5202,"stem":5203,"title":5204,"date":5174,"chapterOrder":5205,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0300-shu-ju-lei-xing-yu-shu-ju-cun-fang","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0300-数据类型与数据存放","Data Types and Data Storage","0300",{"path":5207,"stem":5208,"title":5209,"date":5174,"chapterOrder":5210,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0400-shu-ru-shu-chu","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0400-输入输出","Input and Output","0400",{"path":5212,"stem":5213,"title":5214,"date":5174,"chapterOrder":5215,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0500-yun-suan-fu","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0500-运算符","operator","0500",{"path":5217,"stem":5218,"title":5219,"date":5174,"chapterOrder":5220,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0600-cheng-xu-liu-cheng-jie-gou","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0600-程序流程结构","program flow structure","0600",{"path":5222,"stem":5223,"title":5224,"date":5174,"chapterOrder":5225,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0700-shu-zu","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0700-数组","array","0700",{"path":5171,"stem":5188,"title":5,"date":5174,"chapterOrder":5173,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},{"path":5228,"stem":5229,"title":5230,"date":5174,"chapterOrder":5231,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0900-zhi-zhen","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F0900-指针","pointer","0900",{"path":5233,"stem":5234,"title":5235,"date":5174,"chapterOrder":5236,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1000-jie-gou-ti-yu-gong-yong-ti","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1000-结构体与共用体","Structures and Unions","1000",{"path":5238,"stem":5239,"title":5240,"date":5174,"chapterOrder":5241,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1100-nei-cun-fen-qu-yu-sheng-ming-zhou-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1100-内存分区与生命周期","Memory Partitioning and Lifecycle","1100",{"path":5243,"stem":5244,"title":5245,"date":5174,"chapterOrder":5246,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1200-yin-yong","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1200-引用","reference","1200",{"path":5248,"stem":5249,"title":5250,"date":5174,"chapterOrder":5251,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1300-han-shu-ti-gao-yu-ming-ming-kong-jian","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1300-函数提高与命名空间","Advanced Functions and Namespaces","1300",{"path":5253,"stem":5254,"title":5255,"date":5174,"chapterOrder":5256,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1400-0100-feng-zhuang","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1400-0100-封装","encapsulation","1400-0100",{"path":5258,"stem":5259,"title":5260,"date":5174,"chapterOrder":5261,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1400-0200-dui-xiang-chu-shi-hua-he-qing-li","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1400-0200-对象初始化和清理","Object initialization and cleanup","1400-0200",{"path":5263,"stem":5264,"title":5265,"date":5174,"chapterOrder":5266,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1400-0300-dui-xiang-mo-xing-yu-this-zhi-zhen","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1400-0300-对象模型与this指针","Object Model and the `this` Pointer","1400-0300",{"path":5268,"stem":5269,"title":5270,"date":5174,"chapterOrder":5271,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1400-0400-you-yuan-yu-yun-suan-fu-zhong-zai","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1400-0400-友元与运算符重载","Friends and operator overloading","1400-0400",{"path":5273,"stem":5274,"title":5275,"date":5174,"chapterOrder":5276,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1400-0500-ji-cheng","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1400-0500-继承","inheritance","1400-0500",{"path":5278,"stem":5279,"title":5280,"date":5174,"chapterOrder":5281,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1400-0600-duo-tai","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1400-0600-多态","polymorphism","1400-0600",{"path":5283,"stem":5284,"title":5285,"date":5174,"chapterOrder":5286,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1400-lei-he-dui-xiang","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1400-类和对象","Classes and Objects","1400",{"path":5288,"stem":5289,"title":5290,"date":5174,"chapterOrder":5291,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1500-wen-jian-cao-zuo","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1500-文件操作","File operations","1500",{"path":5293,"stem":5294,"title":5295,"date":5174,"chapterOrder":5296,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1600-yi-chang-chu-li-yu-cuo-wu-ma","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1600-异常处理与错误码","异常处理","1600",{"path":5298,"stem":5299,"title":5300,"date":5174,"chapterOrder":5301,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1700-mu-ban","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1700-模板","template","1700",{"path":5303,"stem":5304,"title":5305,"date":5174,"chapterOrder":5306,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0100-stl-chu-shi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0100-STL初识","Introduction to STL","1800-0100",{"path":5308,"stem":5309,"title":5310,"date":5174,"chapterOrder":5311,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0200-std-array","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0200-std-array","std::array","1800-0200",{"path":5313,"stem":5314,"title":5315,"date":5174,"chapterOrder":5316,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0300-string-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0300-string容器","string container","1800-0300",{"path":5318,"stem":5319,"title":5320,"date":5174,"chapterOrder":5321,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0400-vector-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0400-vector容器","vector 容器","1800-0400",{"path":5323,"stem":5324,"title":5325,"date":5174,"chapterOrder":5326,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0500-deque-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0500-deque容器","deque 容器","1800-0500",{"path":5328,"stem":5329,"title":5330,"date":5174,"chapterOrder":5331,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0600-stack-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0600-stack容器","stack 容器","1800-0600",{"path":5333,"stem":5334,"title":5335,"date":5174,"chapterOrder":5336,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0700-queue-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0700-queue容器","queue container","1800-0700",{"path":5338,"stem":5339,"title":5340,"date":5174,"chapterOrder":5341,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0800-list-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0800-list容器","list 容器","1800-0800",{"path":5343,"stem":5344,"title":5345,"date":5174,"chapterOrder":5346,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-0900-set-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-0900-set容器","set \u002F multiset 容器","1800-0900",{"path":5348,"stem":5349,"title":5350,"date":5174,"chapterOrder":5351,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-1000-map-rong-qi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-1000-map容器","map \u002F multimap 容器","1800-1000",{"path":5353,"stem":5354,"title":5355,"date":5174,"chapterOrder":5356,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-1100-han-shu-dui-xiang-yu-wei-ci","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-1100-函数对象与谓词","Function objects and predicates","1800-1100",{"path":5358,"stem":5359,"title":5360,"date":5174,"chapterOrder":5361,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-1200-chang-yong-suan-fa","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-1200-常用算法","Common algorithms","1800-1200",{"path":5363,"stem":5364,"title":5365,"date":5174,"chapterOrder":5366,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1800-stl-ti-gao-bian-cheng","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1800-STL提高编程","Level up your programming with STL.","1800",{"path":5368,"stem":5369,"title":5370,"date":5174,"chapterOrder":5371,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F1900-c-lei-xing-zhuan-huan","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F1900-C++类型转换","C++ Type Casting","1900",{"path":5373,"stem":5374,"title":5375,"date":5174,"chapterOrder":5376,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0100-auto","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0100-auto","auto","2000-0100",{"path":5378,"stem":5379,"title":5380,"date":5174,"chapterOrder":5381,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0200-nullptr","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0200-nullptr","nullptr","2000-0200",{"path":5383,"stem":5384,"title":1565,"date":5174,"chapterOrder":5385,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0300-using","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0300-using","2000-0300",{"path":5387,"stem":5388,"title":5389,"date":5174,"chapterOrder":5390,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0400-enum-class","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0400-enum-class","enum class","2000-0400",{"path":5392,"stem":5393,"title":5394,"date":5174,"chapterOrder":5395,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0500-fan-wei-for-xun-huan","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0500-范围for循环","range-based for loop","2000-0500",{"path":5397,"stem":5398,"title":5399,"date":5174,"chapterOrder":5400,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0600-jie-gou-hua-bang-ding","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0600-结构化绑定","structured binding","2000-0600",{"path":5402,"stem":5403,"title":5404,"date":5174,"chapterOrder":5405,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0700-constexpr","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0700-constexpr","constexpr","2000-0700",{"path":5407,"stem":5408,"title":5409,"date":5174,"chapterOrder":5410,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0800-raii","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0800-RAII","RAII","2000-0800",{"path":5412,"stem":5413,"title":5414,"date":5174,"chapterOrder":5415,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-0900-zhi-neng-zhi-zhen","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-0900-智能指针","Smart pointer","2000-0900",{"path":5417,"stem":5418,"title":5419,"date":5174,"chapterOrder":5420,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1000-you-zhi-yin-yong-he-yi-dong-yu-yi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1000-右值引用和移动语义","Rvalue references and move semantics","2000-1000",{"path":5422,"stem":5423,"title":5424,"date":5174,"chapterOrder":5425,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1100-lambda-biao-da-shi","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1100-Lambda表达式","Lambda expression","2000-1100",{"path":5427,"stem":5428,"title":5429,"date":5174,"chapterOrder":5430,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1200-std-function","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1200-std-function","std::function","2000-1200",{"path":5432,"stem":5433,"title":5434,"date":5174,"chapterOrder":5435,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1300-std-bind","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1300-std-bind","std::bind","2000-1300",{"path":5437,"stem":5438,"title":5439,"date":5174,"chapterOrder":5440,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1400-std-optional","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1400-std-optional","std::optional","2000-1400",{"path":5442,"stem":5443,"title":5444,"date":5174,"chapterOrder":5445,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1500-std-variant","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1500-std-variant","std::variant","2000-1500",{"path":5447,"stem":5448,"title":5449,"date":5174,"chapterOrder":5450,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1600-std-span","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1600-std-span","std::span","2000-1600",{"path":5452,"stem":5453,"title":5454,"date":5174,"chapterOrder":5455,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1700-std-format-print","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1700-std-format-print","std::format \u002F std::print","2000-1700",{"path":5457,"stem":5458,"title":5459,"date":5174,"chapterOrder":5460,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1800-std-chrono","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1800-std-chrono","std::chrono","2000-1800",{"path":5462,"stem":5463,"title":5464,"date":5174,"chapterOrder":5465,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1900-0100-std-thread","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1900-0100-std-thread","std::thread and join","2000-1900-0100",{"path":5467,"stem":5468,"title":5469,"date":5174,"chapterOrder":5470,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1900-0200-mutex-lock-guard","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1900-0200-mutex-lock-guard","mutex 与 lock_guard","2000-1900-0200",{"path":5472,"stem":5473,"title":5474,"date":5174,"chapterOrder":5475,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1900-0300-std-atomic","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1900-0300-std-atomic","std::atomic","2000-1900-0300",{"path":5477,"stem":5478,"title":5479,"date":5174,"chapterOrder":5480,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1900-0400-condition-variable","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1900-0400-condition-variable","condition_variable","2000-1900-0400",{"path":5482,"stem":5483,"title":5484,"date":5174,"chapterOrder":5485,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-1900-bing-fa-bian-cheng","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-1900-并发编程","Concurrent programming","2000-1900",{"path":5487,"stem":5488,"title":5489,"date":5174,"chapterOrder":5490,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-2000-std-filesystem","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-2000-std-filesystem","std::filesystem","2000-2000",{"path":5492,"stem":5493,"title":5494,"date":5174,"chapterOrder":5495,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-2100-modules-jian-jie","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-2100-modules简介","Modules Introduction","2000-2100",{"path":5497,"stem":5498,"title":5499,"date":5174,"chapterOrder":5500,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2000-xian-dai-c","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2000-现代C++","Modern C++","2000",{"path":5502,"stem":5503,"title":5504,"date":5174,"chapterOrder":5505,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0100-0100-ding-shi-qi-yu-yi-bu-io","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0100-0100-定时器与异步IO","Timers and Asynchronous I\u002FO","2100-0100-0100",{"path":5507,"stem":5508,"title":5509,"date":5174,"chapterOrder":5510,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0100-0200-boost-asio-ji-chu","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0100-0200-Boost.Asio基础","Boost.Asio Basics","2100-0100-0200",{"path":5512,"stem":5513,"title":5514,"date":5174,"chapterOrder":5515,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0100-0300-chuan-kou-tong-xin","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0100-0300-串口通信","serial communication","2100-0100-0300",{"path":5517,"stem":5518,"title":5519,"date":5174,"chapterOrder":5520,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0100-0400-tcp-tong-xin","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0100-0400-TCP通信","TCP communication","2100-0100-0400",{"path":5522,"stem":5523,"title":5524,"date":5174,"chapterOrder":5525,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0100-0500-udp-tong-xin","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0100-0500-UDP通信","UDP communication","2100-0100-0500",{"path":5527,"stem":5528,"title":5529,"date":5174,"chapterOrder":5530,"chapterDepth":81,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0100-0600-ji-qi-ren-gong-cheng-xie-fa-yu-ros2-ji-cheng","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0100-0600-机器人工程写法与ROS2集成","Robot Engineering Approach and ROS2 Integration","2100-0100-0600",{"path":5532,"stem":5533,"title":5534,"date":5174,"chapterOrder":5535,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0100-boost-asio-yi-bu-io-ku","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0100-Boost.Asio异步IO库","Boost.Asio asynchronous IO library","2100-0100",{"path":5537,"stem":5538,"title":5539,"date":5174,"chapterOrder":5540,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0200-eigen-xian-xing-dai-shu-ku","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0200-Eigen线性代数库","Eigen linear algebra library","2100-0200",{"path":5542,"stem":5543,"title":5544,"date":5174,"chapterOrder":5545,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0300-opencv-ji-suan-ji-shi-jue-ku","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0300-OpenCV计算机视觉库","OpenCV Computer Vision Library","2100-0300",{"path":5547,"stem":5548,"title":5549,"date":5174,"chapterOrder":5550,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0400-pcl-dian-yun-ku","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0400-PCL点云库","PCL Point Cloud Library","2100-0400",{"path":5552,"stem":5553,"title":5554,"date":5174,"chapterOrder":5555,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-0500-sophus-li-qun-li-dai-shu-ku","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-0500-Sophus李群李代数库","Sophus Lie group and Lie algebra library","2100-0500",{"path":5557,"stem":5558,"title":5559,"date":5174,"chapterOrder":5560,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2100-chang-yong-ku","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2100-常用库","Learning Common Libraries","2100",{"path":5562,"stem":5563,"title":5564,"date":5174,"chapterOrder":5565,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2200-0100-cmakepresets-yu-gou-jian-an-zhuang","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2200-0100-CMakePresets与构建安装","CMakePresets and Build Installation","2200-0100",{"path":5567,"stem":5568,"title":5569,"date":5174,"chapterOrder":5570,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2200-0200-ding-ceng-cmake-yu-gong-gong-bian-yi-xuan-xiang","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2200-0200-顶层CMake与公共编译选项","Top-level CMake and Public Compilation Options","2200-0200",{"path":5572,"stem":5573,"title":5574,"date":5174,"chapterOrder":5575,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2200-0300-src-yu-lib-mo-kuai-cmake-xiang-jie","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2200-0300-src与lib模块CMake详解","Detailed CMake Explanation for src and lib Modules","2200-0300",{"path":5577,"stem":5578,"title":5579,"date":5174,"chapterOrder":5580,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2200-0400-di-san-fang-ku-yi-lai-xie-fa","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2200-0400-第三方库依赖写法","How to write third-party library dependencies","2200-0400",{"path":5582,"stem":5583,"title":5584,"date":5174,"chapterOrder":5585,"chapterDepth":74,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2200-0500-mu-ban-kuo-zhan-yu-chang-jian-wen-ti","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2200-0500-模板扩展与常见问题","Template Extensions and FAQ","2200-0500",{"path":5587,"stem":5588,"title":5589,"date":5174,"chapterOrder":5590,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":5181},"\u002Fen-us\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F2200-cmake-gong-cheng-mu-ban","_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002F2200-CMake工程模板","CMake Project Template","2200",{"path":5177,"stem":5592,"title":5593,"date":5174,"chapterOrder":5182,"chapterDepth":5172,"docKey":5176,"docRoot":5177,"docTitle":5178,"isWikiDoc":90,"isWikiIndex":90},"_i18n\u002Fen-us\u002Fwiki\u002F2023-10-05-Cplusplus教学\u002Findex","C\u002FC++ tutorial",{"variants":5595},[5596,5597,5600,5603,5606],{"path":5171,"localeSlug":5184,"i18nKey":5180},{"path":5598,"localeSlug":5599,"i18nKey":5180},"\u002Fzh-hant\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian","zh-hant",{"path":5601,"localeSlug":5602,"i18nKey":5180},"\u002Fzh-hk\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian","zh-hk",{"path":5604,"localeSlug":5605,"i18nKey":5180},"\u002Fzh-tw\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian","zh-tw",{"path":5607,"localeSlug":5608,"i18nKey":5180},"\u002Fzh-cn\u002Fwiki\u002F2023-10-05-cplusplus-jiao-xue\u002F0800-han-shu-yu-tou-wen-jian","zh-cn",[5171,5187,5598,5187,5601,5187,5604,5187,5607,5187],1784646861832]