鍍金池/ 問答/ C++問答
魚梓 回答

1,在map_test.cpp文件中定義map<string, string> map_config;
2,在map_test.h中使用extern map<string, string> map_config;

奧特蛋 回答
嚴格來講,JavaScript 中沒有私有成員的概念;所有對象屬性都是公有的。不過,倒是有一個私有變量的概念。任何在函數(shù)中定義的變量,都可以認為是私有變量,因為不能在函數(shù)的外部訪問這些變量。

私有變量包括函數(shù)的參數(shù)、局部變量和在函數(shù)內(nèi)部定義的其他函數(shù)。

    var Oop = (function () {
    
      var a = 'A'// 靜態(tài)私有變量,因為每個 Oop 的實例共享同一個 a
    
      function Oop() {
        // private私有變量,實例變量
        var _private = 'private'    

        this.name = 'james'
      }
    
      Oop.prototype = {//此處應(yīng)為 Oop 非 vue
        constructor: Oop,
        consoleName: function () { // public公共方法、公有方法
          console.log(this.name)
        }
      }
    
      Oop.staticFunc = function () { } // static靜態(tài)方法
    
      return Oop
    })()

另外,還有個特權(quán)方法

function MyObject(){
//私有變量和私有函數(shù)
    var privateVariable = 10;
    function privateFunction(){
        return false;
    }
//特權(quán)方法(可以訪問私有變量和函數(shù)的公有方法)
    this.publicMethod = function (){
        privateVariable++;
        return privateFunction();
    };
}

摘自JavaScript高級程序設(shè)計-第3版-中

念舊 回答

合法。不合理。data1可能不會是你預(yù)想中的數(shù)據(jù)

凝雅 回答

因為 -c 作為 printf 的參數(shù)時,默認轉(zhuǎn)換成 int 類型了。

請參考編譯器生成的匯編指令, x86_64 gcc 7.3, https://godbolt.org/

.LC0:
  .string "%d"
main:
  push rbp
  mov rbp, rsp
  sub rsp, 16
  mov BYTE PTR [rbp-1], -128
  movsx eax, BYTE PTR [rbp-1]
  neg eax
  mov esi, eax              // eax 是 printf 的第二個參數(shù),請向上追溯。
  mov edi, OFFSET FLAT:.LC0
  mov eax, 0
  call printf
  mov eax, 0
  leave
  ret

作為對比,強制轉(zhuǎn)換成 char 類型變成這樣

#include<stdio.h>
int main()
{
    char c=-128;
    printf("%d", (char)(-c));
}

編譯后

.LC0:
  .string "%d"
main:
  push rbp
  mov rbp, rsp
  sub rsp, 16
  mov BYTE PTR [rbp-1], -128
  movzx eax, BYTE PTR [rbp-1]
  neg eax
  movsx eax, al              // 強制轉(zhuǎn)換類型后,多了這一行。
  mov esi, eax               // eax 是 printf 的第二個參數(shù),請向上追溯。
  mov edi, OFFSET FLAT:.LC0
  mov eax, 0
  call printf
  mov eax, 0
  leave
  ret
墨小白 回答

常量區(qū),屬于常量字符串。

薔薇花 回答

decimal帶兩位小數(shù),更精準一些

遲月 回答

利用es6的Set吧
求并集,判斷size

const s1 = 'abcsk'
const s2 = 'abnn'
if (new Set(s1).size === new Set(s1 + s2).size) {
    // 說明s2里面只有s1的元素
} else {
    // 說明s2里面含有s1意外的元素
}
莫小染 回答

外部不外部的,這只是extern這個關(guān)鍵字的字面意思。
實際中,變量加extern的用意是“只聲明而不定義一個變量”,類似于寫一個沒有函數(shù)體的函數(shù)。

苦妄 回答

在/root/.bitcoin/下面創(chuàng)建配置文件bitcoin.conf

cp ./contrib/debian/examples/bitcoin.conf /root/.bitcoin/

直接運行bitcoind
bitcoind

查看端口8332
lsof -i:8332
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bitcoind 8331 root 9u IPv6 308456 0t0 TCP *:8332 (LISTEN)

扯機薄 回答

你完全可以使用一個第三方庫來解決這個問題,https://github.com/truizlop/S...

真難過 回答

文件操作模式介紹

clipboard.png

問題中的錯誤

modefread 不對應(yīng)。
(仔細閱讀 mode 說明。)

正確使用方式,請自行參考:

奧特蛋 回答
  1. 如果是阻塞式的,那只能代表數(shù)據(jù)已發(fā)出去,但不能保證對方已收到;如果是非阻塞式的,select到OP_WRITE就說明數(shù)據(jù)已發(fā)出去;無論哪種方式似乎都無法確保對方收到,除非對方用數(shù)據(jù)來應(yīng)答;
  2. 對方宕機(或者拔網(wǎng)線),理論上我方是無法知道狀態(tài)的,如果對方進程被kill掉,那么操作系統(tǒng)可能會給回一個FINRST,你應(yīng)該會select到一個OP_READ,并在read時得到-1或異常。
局外人 回答

這是一個全排列的問題嘛

#include <iostream>  
#include <algorithm>
#include <vector>
#include <string>
using namespace std;  
int main()  
{  
    string color[2] = {"黑","白"};
    vector<int> vec = {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1};  
    do {  
       for(auto& i:vec){
          cout<<color[i]<<',';
       }
       cout<<endl;
    } while(next_permutation(vec.begin(),vec.end()));  
    return 0;
}
墨小羽 回答

第二個 for 循環(huán)不對:

    for(; i < min(s1.size(), s2.size()); i++){
        if(s1[i] == s2[i]){
            if(s1[i] >= 'A' && s1[i] <= 'N')
                cout << 10 + s1[i] - 'A' << ":";
            else if(isdigit(s1[i]))
                cout << '0' << s1[i] << ":";
            // 此處別的情況呢?如果匹配了不是數(shù)字也不是 A~N 的字母,循環(huán)仍要繼續(xù)
            break;
        }
    }
墨染殤 回答

C#是半默認break,你不寫會編譯器會發(fā)錯誤

故林 回答

It must be a typographical error. There is no doubt that


$$\mathrm{dot}((p - C),(p - C)) = (x - cx) \cdot (x-c) + (y - cy) \cdot (y - cy) + (z - cz) \cdot (z - cz)$$


$\text{BTW}, \ \ \ \cdot \ \ \ \text{is much more popular than} \ \ \ \ \times \ \ \ \ \ \ast \ \ \ \ \ \text{in mathematics}$

喜歡你 回答

應(yīng)該用celery起異步任務(wù)做

懶洋洋 回答

你的問題解決了嗎?
解決了和我說一下怎么解決的好嗎,1365413148@qq.com我的郵箱,萬分感謝