小编asy*_*Fan的帖子

Pharo 中的 at ("@") 运算符是什么?

我在网上寻找@Pharo 中运算符的含义,但找不到任何内容。

Pharo@运算符的含义是什么?例如,为什么25@50被评估为:"(25@50)"

pharo

4
推荐指数
1
解决办法
157
查看次数

多线程分段故障(for loop)

为什么以下代码会给我一个分段错误:

#include<iostream>
#include<thread>
#include<vector>

using namespace std;


double f(double a, double b, double* c) {
    *c = a + b;
}

int main() {
   vector<double> a ={1,2,3,4,5,6,7,8};                     
   vector<double> b ={2,1,3,4,5,2,8,2};                    
   int size = a.size();
   vector<double> c(size);                               
   vector<thread*> threads(size);

   for (int i = 0; i < size; ++i) {
        thread* t = new thread(f, a[i], b[i], &c[i]);             
        threads.push_back(t);
   }

   for (vector<thread*>::iterator it = threads.begin(); it != threads.end();     it++) {
       (*it)->join();                                      
   }

   cout << "Vector c is: ";
   for (int i =0; …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading vector segmentation-fault

0
推荐指数
2
解决办法
204
查看次数

标签 统计

c++ ×1

multithreading ×1

pharo ×1

segmentation-fault ×1

vector ×1