小编Job*_*Job的帖子

为什么在用g ++编译时会出现符号引用错误?

aludra.usc.edu(25): g++ -o final.out final.cpp 
Undefined                       first referenced
 symbol                             in file
data::Get_Networth()                /var/tmp//ccUz9c59.o
data::Set_Networth(double)          /var/tmp//ccUz9c59.o
data::Get_Heightfeet()              /var/tmp//ccUz9c59.o
data::Get_Lettergpa()               /var/tmp//ccUz9c59.o
data::Set_Weight(int)               /var/tmp//ccUz9c59.o
data::Get_Weight()                  /var/tmp//ccUz9c59.o
data::Get_Major()                   /var/tmp//ccUz9c59.o
data::Set_Gpa(double)               /var/tmp//ccUz9c59.o
data::Get_GPA()                     /var/tmp//ccUz9c59.o
data::Set_Age(int)                  /var/tmp//ccUz9c59.o
data::Get_Age()                     /var/tmp//ccUz9c59.o
data::Set_Major(std::basic_string, std::allocator               >)/var/tmp//ccUz9c59.o
data::Set_Data(std::basic_string, std::allocator >,     int, int, int, double, std::basic_string, std::allocator >, double)/var/tmp//ccUz9c59.o
data::Get_Heightfeetremainder()     /var/tmp//ccUz9c59.o
data::Set_Heightinches(int)         /var/tmp//ccUz9c59.o
data::data()                        /var/tmp//ccUz9c59.o
data::Get_Name()                    /var/tmp//ccUz9c59.o
data::Get_Heightinches()            /var/tmp//ccUz9c59.o
ld: fatal: Symbol referencing errors. No output written to final.out
collect2: ld returned 1 exit status

这是我在Solaris中编译时不断使用g ++的内容.该代码在VS2010中完美编译.所以我无法弄清楚出了什么问题.

这是我的类文件的代码data.h:

    #include <string>


using namespace …
Run Code Online (Sandbox Code Playgroud)

c++ g++

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

没有用于调用复制构造函数的匹配函数

我有一个类Graph,其复制构造函数在Graph.h中声明如下:

template<typename Object,typename Weight>              
Graph<Object,Weight>::Graph(Graph<Object,Weight>& G)
Run Code Online (Sandbox Code Playgroud)

在其他地方,我尝试使用它:

Graph<double,double> G = make_graph("dense.g");
Run Code Online (Sandbox Code Playgroud)

...但是它给了我以下错误:

time_trialsALIST.cpp:37: error: no matching function for call to `Graph::Graph(Graph)'
Graph.h:142: note: candidates are: Graph::Graph(Graph&) [with Object = double, Weight = double]

我不明白为什么会这样; make_graph函数只返回一个Graph:

Graph<double,double>  make_graph(string filename){...} 
Run Code Online (Sandbox Code Playgroud)

在某个地方我需要一个'&'吗?

c++ no-match

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

C++中的非法成员初始化

class ZooAnimal {
public:
virtual void draw();
int resolveType() {return myType;}
protected:
int myType;
};

class Bear : public ZooAnimal {
public:
Bear (const char *name) : myName(name), myType(1){}
void draw(){ };
private:
    std::string myName;
};

void main()
{

}
Run Code Online (Sandbox Code Playgroud)

当我编译上面的代码时,我正在跟踪错误

错误C2614:'熊':非法成员初始化:'myType'不是基础或成员

为什么我会在错误之上纠结错误,因为我们可以从派生的calss访问受保护的成员?

c++

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

C程序中的ASM代码导致分段错误

我在一个小程序中包含了一些示例ASM代码来进行测试.

我的计划是:

#include <stdio.h>

static inline
unsigned char inb (int port) {
    unsigned char data;
    asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
    return data;
}

int main()
{
    printf("hello world %d\n", inb(22));
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我运行程序时,它在执行ASM代码时因分段错误而崩溃.有人能告诉我这个小程序有什么问题吗?非常感谢.

c linux x86 gcc inline-assembly

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

STL Map作为默认参数

如何将stl map作为默认参数传递?

c++ stl

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

python代码到c ++ lib或dll

我有一些我想在C++中使用的python代码,我想在lib或dll中构建它?我该怎么做?代码有依赖关系:

import socket
import string
import struct
import sys
Run Code Online (Sandbox Code Playgroud)

也许是PIL

c++ python dll

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

C ++段故障问题

我正在使用一些外部C库的C ++程序上工作。据我所知,这不是问题的原因,而问题出在我的C ++代码上。该程序运行良好,没有错误,也没有测试数据集上的任何内容,但是经过几乎整个完整数据集后,出现了段错误。运行GDB给了我这个段错误:

(gdb)运行-speciesMain = allMis1 -speciesOther = anoCar2 -speciesMain = allMis1 -speciesOther = anoCar2 /hive/data/genomes/allMis1/bed/lastz.anoCar2/mafRBestNet/*.maf.gz
启动程序:/ cluster / home / jstjohn / bin / mafPairwiseSyntenyDecay -speciesMain = allMis1 -speciesOther = anoCar2 -speciesMain = allMis1 -speciesOther = anoCar2 / hive / data / genome
s / allMis1 / bed / lastz.anoCar2 / mafRBestNet / *。maf.gz
从子进程3718中叉后拆卸。

程序收到信号SIGSEGV,分段故障。
来自/usr/lib64/libstdc++.so.6的__gnu_cxx :: __ exchange_and_add(int volatile *,int)()中的0x0000003009cb7672
(gdb)向上
/usr/lib64/libstdc++.so.6中的std :: basic_string,std :: allocator> ::〜basic_string()()中的#1 0x0000003009c9db59
(gdb)向上
在mafPairwiseSyntenyDecay.cpp中的#2 0x00000000004051e7在PairAlnInfo :: ~~ PairAlnInfo(this = 0x7fffffffcd70,__in_chrg =)中 …

c++ memory-management segmentation-fault

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