我有一个关于C++析构函数的问题。类析构函数C++
我有一类这样的:
class X {
private:
string m_instanceName
string m_path;
ConnexionHashMap m_connexions;
Module** m_moduleType;
Powerdomain* m_powerDomain;
Module ** m_father;
};
下面是一些有关的信息ConnexionHashMap:
typedef hash_map<const string, Connexion, strptrhash, strptrequal> ConnexionHashMap;
struct Net{
string name;
vector<string> connectedPins;
bool isPin;
};
typedef struct Net Net;
struct Connexion{
string pin;
Net* net;
};
typedef struct Connexion Connexion;
如果我不想删除m_modulType的m_powerDomain和m_father(因为它们很可能会被另一个对象引用),我是否必须明确地编写一个析构函数方法?
我知道这个字符串是一个标准对象,并且会被它自己的析构函数销毁,但是ConnexionHashMap会被标准hashmap模板析构函数销毁还是应该以某种方式手动删除它?
(也对阿里纳斯有一个简单的方法,看看我的程序是在Eclipse CDT的运行,而我的内存是如何管理的?)
相当无关点评:在C++中,你不需要明确的typedef一个结构使用它无线没有结构关键字。结构就像一个类(但默认情况下声明为公共成员)。 – 2011-05-25 14:29:54
这是不相关的,但仍然有用,谢谢你的提示;) – djfoxmccloud 2011-05-25 14:33:13
CDT有一个控制台界面GDB?如果是这样,你总是可以发出命令'x',例如'x myptr'或'x/64xb'(显示64字节为十六进制)。参考http://sourceware.org/gdb/current/onlinedocs/gdb/ Memory.html#Memorygdb_56.html – Skurmedel 2011-05-25 14:37:42