小编MrR*_*ROY的帖子

为什么我的C++类定义失败?

main.cpp中

#include <iostream>
#include "Burrito.h"

using namespace std;

int main(){
  Burrito b;
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

Burrito.h

#ifndef BURRITO_H
#define BURRITO_H

class Burrito{
    public:
      Burrito();
};

#endif
Run Code Online (Sandbox Code Playgroud)

Burrito.cpp

#include "Burrito.h"
#include <iostream>

Burrito::Burrito(){

}
Run Code Online (Sandbox Code Playgroud)

编译和链接:

lzsb$ g++ main.cpp -o main
Undefined symbols for architecture x86_64:
  "Burrito::Burrito()", referenced from:
      _main in ccVpCr0z.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
lzsb$ 
Run Code Online (Sandbox Code Playgroud)

平台:

Mac OS 10.6.8

G++ : i686-apple-darwin10 --with-gxx-include-dir=/usr/include/c++/4.2.1
Run Code Online (Sandbox Code Playgroud)

c++ gcc g++

2
推荐指数
1
解决办法
300
查看次数

为什么我的 golang 无锁队列总是卡在那里?

这是我的代码:

package main

import (
    "sync/atomic"
    "unsafe"
    "sync"
    "fmt"
    "time"
)

const (
    MAX_DATA_SIZE = 100
)

// lock free queue
type Queue struct {
    head unsafe.Pointer
    tail unsafe.Pointer
}
// one node in queue
type Node struct {
    val interface{}
    next unsafe.Pointer
}
// queue functions
func (self *Queue) enQueue(val interface{}) {
    newValue := unsafe.Pointer(&Node{val: val, next: nil})
    var tail,next unsafe.Pointer
    for {
        tail = self.tail
        next = ((*Node)(tail)).next
        if next != nil {
            atomic.CompareAndSwapPointer(&(self.tail), tail, next)
        }else if …
Run Code Online (Sandbox Code Playgroud)

go

2
推荐指数
1
解决办法
2985
查看次数

如何对某些十进制数据应用scikit-learn的LogisticRegression?

我的训练数据集如下:

0.00479616 |  0.0119904 |  0.00483092 |  0.0120773 | 1
0.51213136 |  0.0113404 |  0.02383092 |  -0.012073 | 0
0.10479096 |  -0.011704 |  -0.0453692 |  0.0350773 | 0
Run Code Online (Sandbox Code Playgroud)

前4列是一个样本的特征,最后一列是其输出.

我用这种方式使用scikit:

  data = np.array(data)
  lr = linear_model.LogisticRegression(C=10)

  X = data[:,:-1]
  Y = data[:,-1]
  lr.fit(X, Y)

  print lr
  # The output is always 1 or 0, not a probability number.
  print lr.predict(data[0][:-1])
Run Code Online (Sandbox Code Playgroud)

我认为Logistic回归总是应该给出介于0和1之间的概率数.

python machine-learning linear-regression logistics scikit-learn

2
推荐指数
1
解决办法
2万
查看次数

playframework:启动时出现NullpointerException

我正在使用Play 1.2.7,不知怎的,我发现我的项目变得很奇怪,当我启动应用程序并访问任何有效的URL时,它显示NullPointerException:

Oops: NullPointerException
An unexpected error occured caused by exception NullPointerException: null

play.exceptions.UnexpectedException: Unexpected Error
    at play.Play.start(Play.java:563)
    at play.Play.detectChanges(Play.java:637)
    at play.Invoker$Invocation.init(Invoker.java:198)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
    at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:266)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:478)
    at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:282)
    at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:426)
    at play.Play.start(Play.java:523)
    ... 3 more
Run Code Online (Sandbox Code Playgroud)

然后我尝试刷新页面,2或3次后,它变得正常.这里发生了什么?

java playframework-1.x

2
推荐指数
1
解决办法
877
查看次数

无法访问C++向量下的内存

我在我的程序中使用了一个向量,如下所示:

vector<vector<string> > values;
values[0].push_back("test words");
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,它显示"段错误"

然后我尝试gdb它,我得到了这个:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008
0x00000001000035be in std::vector<std::string, std::allocator<std::string> >::push_back (this=0x0, __x=@0x7fff5fbff330) at stl_vector.h:602
602     if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
Run Code Online (Sandbox Code Playgroud)

这里发生了什么 ?

c++ gdb g++ stdvector

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

如何在Java中获取类的所有公共静态方法?

clazz.getDeclaredMethods()将返回所有方法,但我只想要那些public static方法,我该如何制作呢?

java

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

cin一个非常大的int数组,段错误11

这是我的代码:

int main(){
    int n = 0;
    std::cin>>n;
    int lh[n][2];

    for(int i = 0; i < n; i++) {
        std::cin>>lh[i][0]>>lh[i][1];
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我不知道为什么,如果n非常小,它运行正常,但是当n更大,比如10,000,000时,就会发现segmentfault 11错误.

这里发生了什么 ?

c++

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

Shell:如何处理在shell脚本中包含`\n`或``的文件名

我有这样的shell脚本:

#!/bin/bash
if [ $# -lt 1 ]
then
  echo "Use: "$0" <file_name>"
  echo "Convert files from GBK to UTF8"
  exit
fi

for i in $*

  # Generate temp file to avoid Bus error
  iconv -f GBK -t utf-8 "$i" -o "$i.tmp"
  mv "$i.tmp" "$i"
done
Run Code Online (Sandbox Code Playgroud)

问题是$i可以含有\n,或其他有线字符,使得脚本执行失败(即使我已经用""把它包).有没有办法忽略那些角色?

bash shell

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

Java:有没有办法将String放入List <Integer>?

面试问题:

String对象可以是任何格式,不仅numbers表示.

java

-2
推荐指数
1
解决办法
105
查看次数