我用这个命令行得到了这个未定义的符号构建:
$ gcc test.cpp
Undefined symbols:
"___gxx_personality_v0", referenced from:
etc...
Run Code Online (Sandbox Code Playgroud)
test.cpp很简单,应该很好.这笔交易是什么?
我正在研究用C++学习OOP并遇到问题.我确定它是一个内存分配问题,但似乎无法理解它.任何帮助将不胜感激.
我的客户代码
#include <iostream>
#include "Box.cpp"
using namespace std;
int main(){
Box *box = new Box;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的盒子类......
#include <iostream>
using namespace std;
class Box{
private:
double width;
double height;
double perimeter;
double area;
public:
Box(){
cout << "Box created" << endl;
}
~Box(){
cout << "Box Destroyed" << endl;
}
double getWidth(){
//
return this->width;
}
double getHeight(){
//
return this->height;
}
double getArea(){
//
return this->area;
}
double getPerimeter(){
//
return this->perimeter;
}
void setWidth(double w){ …Run Code Online (Sandbox Code Playgroud) 我有Arm处理器,它是AllWinner A13,RAM-512mb和OS-Linaro 13.01 Ubuntu(意思是debian).现在我正在为/ dev/ttyS0制作串行通信程序.我使用netbeans在java中为双向串行通信制作了简单的程序.在我的处理器中,我将ttyS0的rx-tx缩短为环回连接检查.意味着我通过串口发送的东西,我回来了.但我得到错误.我在我的处理器上安装了openjdk-7,librxtx-java.我的代码和错误如下.如果有任何想法或解决方案,请告诉我.
package serialcomm_linaro;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class TwoWaySerialComm
{
public TwoWaySerialComm()
{
super();
}
void connect ( String portName ) throws Exception
{
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
if ( portIdentifier.isCurrentlyOwned() )
{
System.out.println("Error: Port is currently in use");
}
else
{
CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
if ( commPort instanceof SerialPort )
{
SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
InputStream in = serialPort.getInputStream();
OutputStream out …Run Code Online (Sandbox Code Playgroud) 嗨,有人可以告诉为什么在Linux和Windows中出现同样的问题:
#include <iostream>
using namespace std;
class A
{
private:
int _dmember;
public:
void func()
{
cout<<"Inside A!! "<<endl;
cout<<_dmember; // crash when reach here.
}
};
int main ()
{
A* a= NULL;
a->func(); // prints "Inside A!!!"
return 1;
}
Run Code Online (Sandbox Code Playgroud)
有人能说出为什么会发生这种奇怪的事情吗?我的意思是,a-> func()不应该进入func(),...?这是不了解的行为,
为什么上面的behivor会发生?
编辑:当然,*= null是故意的!! 所以对于所有回答"这是未定义的行为"或"你永远不应该尝试在NULL指针上调用函数!!"的人来说,来吧....这就是重点.有些人正确解释了这种行为.