I'm still a bit shaky about C++'s copy and assignment constructors. So far what I have is in A.hpp:
class A {
private:
char* str;
public:
A(char* str);
// strcpy str from other to this.
A(const A& other);
// free str in this, and strcpy str from other to this.
A& operator=(const Type& other);
}
Assuming I have A* a = new A(some_char_str);
, I'm able to write A b = *a;, and b is a deep copy of a.
Now the problem is that I want the ability to write A* b = new A(a); So how can I specify a constructor that takes a pointer to A and create a new A on the heap?