Hi,
I've written a program that uses two objects that look like the ones below, and I was wondering why i would need an assignment operator and copy constructor for either of these classes. Are strings like char*
(dynamic memory)? It would not be difficult to write these methods, I'm just wondering why? txs
Class A
class ClassA
{
public:
ClassA(string aString, ClassA* aLink):x(aString), link(aLink){}
ClassA* getLink() const { return link;}
string getString() const { return x;}
private:
string x;
ClassA* link;
};
ClassB
const int SIZE = 1000;
class ClassB
{
public:
///some methods to do various things
private:
ClassA* array[SIZE];
int func1(string aString);
ClassA* func2(ClassA* pointer, const string& aString);
};