4 major parts to focus on
vector_2d& operator+=(const vector_2d& rhs){
x += rhs.x;
y += rhs.y;
return *this;
}
Vtuber::Vtuber (const string& _name){
name = _name;
follower_max = 2;
follower_num = 0;
followers = new Followers*[follower_max];
for (int i = 0; i < followers_max; i++)
followers[i] = NULL;
}
insert_followervoid Vtuber::insert_follower(const string& name, int age){
// increase number of followers right away
follower_num++;
// search for an empty spot
for (int i = 0; i < follower_max; i++){
// meaning I found an empty spot
if (followers[i] == NULL){
// insert a new follower and return
followers[i] = new Follower(name, age);
return; // we don't need any if condition in this entire function cuz of this
}
}
// if we didn't return by now, it means we didnt find an empty spot (array full)
// we need to create a bigger array with double the size
Follower** new_followers = new Followers*[2*follower_max];
// copy from the old array into the new array;
for (int i = 0; i < followers_max*2; i++){
if (i < follower_max)
new_followers[i] = followers[i];
else
new_follower[i] = NULL;
}
// insert the new follower (minus 1 since our array indices start at 0)
new_follower[follower_num-1] = new Follower(age, name);
// update follower_max
follower_max *= 2;
// get rid of the old followers array
// i can do this without having to free each follower since i reused the same
// follower objects in the new followers array (they won't be dangling)
delete followers;
}
remove_followervoid Vtuber::remove_follower(const string& name){
for (int i = 0; i < follower_max; i++){
if (follower[i] = NULL)
continue;
if (followers[i].getName() == name){
delete followers[i];
followers[i] = NULL;
}
}
}
~Vtuber