I just want to make sure if I understand the properties of pointers. So if I have something like this:
#include <iostream>
using namespace std;
class Person
{
public:
Person(){myBook = new Book(4);}
void printPerson()
{
int i =0;
while(i<n)
{
cout<<myBook[i].n<<endl;
i++;
}
}
private:
Book *myBook;
int n;
};
class Book
{
public:
Book(int num)
{
int n =0;
}
int n;
};
Since the instance of Person class is a pointer, when I try to make a copy constructor and assignment operator=, I have to allocate a new Book for the new Person object. am I right? thx