c – *** glibc检测到*** ./main:双重免费或腐败(fasttop):0x0
失败的路线:Xplano.ubicacion(Eureca.getCoordenadaX(),Eureca.getCoordenadaY())
main.cpp中的位置,但是源代码中的大部分信息都是向下的. 谢谢.
main.cpp中 #include <iostream> #include "Coordenada.cpp" #include "plano.cpp" #include <string> using namespace std; int main (){ int x; int y; x = y = 0; std::cout << "Digite la Coordenada X:" << std::endl; std::cin >> x; std::cout << "Digite la Coordenada Y:" << std::endl; std::cin >> y; Coordenada Eureca; Plano Xplano; Eureca.setCoordenadaX(x); Eureca.setCoordenadaY(y); std::cout << "X es: " << Eureca.getCoordenadaX() << std::endl; std::cout << "Y es: " << Eureca.getCoordenadaY() << std::endl; std::cout << "Ubicado en el " << Xplano.ubicacion(Eureca.getCoordenadaX(),Eureca.getCoordenadaY()) << std::endl; Eureca.~Coordenada(); Xplano.~Plano(); return 0; } Plano.CPP #include <iostream> #include <string> #include "plano.hpp" using namespace std; using std::string; Plano::Plano(){ubicacionX = "desconocido";} Plano::~Plano(){} string Plano::ubicacion(int x,int y) { if ((x=0) && (y=0)){this->ubicacionX = "origen";} return (this->ubicacionX);} Plano.HPP #ifndef _PLANO_HPP #define _PLANO_HPP #include <string> using std::string; class Plano{ private: string ubicacionX; public: Plano(); ~Plano(); string ubicacion(int x,int y); }; #endif 解决方法
您不需要显式调用对象析构函数.当对象超出范围时,将隐式调用它们的析构函数.您需要删除以下两行代码:
// Eureca.~Coordenada(); // Xplano.~Plano(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Cocos2dx Failed to write injected code block to PDB
- u-boot系统移植
- SQLite3 C/C++ 开发接口简介(API函数) 一
- 条件超前/滞后功能PostgreSQL?
- 【设计模式】:Dao设计模式详解及一个简单的项目(AJAX+JSP
- appcompat_v7/res/values-v21/themes_base.xml No resource
- 为什么我的sbt项目依赖不起作用? (坚持试图远程获取它)
- vue2.0开发实践总结之疑难篇
- ruby-on-rails – 如果不使用Rails,值得学习Ruby?
- JSON.parse: unexpected character