Should I delete the string members of a C++ class?
- by Bobby
If I have the following declaration:
#include <iostream>
#include <string>
class DEMData
{
private:
int bitFldPos;
int bytFldPos;
std::string byteOrder;
std::string desS;
std::string engUnit;
std::string oTag;
std::string valType;
int idx;
public:
DEMData();
DEMData(const DEMData &d);
void SetIndex(int idx);
int GetIndex() const;
void SetValType(const char* valType);
const char* GetValType() const;
void SetOTag(const char* oTag);
const char* GetOTag() const;
void SetEngUnit(const char* engUnit);
const char* GetEngUnit() const;
void SetDesS(const char* desS);
const char* GetDesS() const;
void SetByteOrder(const char* byteOrder);
const char* GetByteOrder() const;
void SetBytFldPos(int bytFldPos);
int GetBytFldPos() const;
void SetBitFldPos(int bitFldPos);
int GetBitFldPos() const;
friend std::ostream &operator<<(std::ostream &stream, DEMData d);
bool operator==(const DEMData &d) const;
~DEMData();
};
what code should be in the destructor? Should I "delete" the std::string fields?