小编Lar*_*art的帖子

构造函数中的分段错误

我尝试在C++中创建的每个类都会发生这种情况.从java迁移,我发现问题主要在于创建类.我运行valgrind并且它在构造函数中,它似乎是.

==30214== Memcheck, a memory error detector
==30214== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==30214== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==30214== Command: ./CoC
==30214== 
==30214== 
==30214== Process terminating with default action of signal 11 (SIGSEGV)
==30214==  Bad permissions for mapped region at address 0x404B4F
==30214==    at 0x4C2B9EC: strcat (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30214==    by 0x404220: Model::Model(std::string) (in /home/kronus/Apollo/CoC)
==30214==    by 0x402617: main (in /home/kronus/Apollo/CoC)
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我正在尝试将此模型类的构造函数调用到main方法中.这是构造函数的代码

Model::Model(std::string filename)
{
m_TotalFaces = …
Run Code Online (Sandbox Code Playgroud)

c++ header-files memory-segmentation

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

标签 统计

c++ ×1

header-files ×1

memory-segmentation ×1