#include <iostream>
using namespace std;
class TestClass {
char* m_data;
int m_size;
public:
TestClass(void)
{
m_size = 0;
}
~TestClass(void)
{
if (m_data)
delete[] m_data;
}
void copyData(const char* data, int _size)
{
m_data = new char[_size];
memcpy(m_data, data, _size);
m_size = _size;
}
int getDataSize(void) const
{
return m_size;
}
};
void showSize(TestClass a)
{
cout << "size = " << a.getDataSize() << endl;
}
int main()
{
const char* const szData = "ABC";
TestClass a;
a.copyData(szData,strlen(szData)+1);
showSize(a);
return 0;
}
慕侠2389804
噜噜哒
相关分类