ex01 finished
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/10 11:22:21 by aortigos #+# #+# */
|
||||
/* Updated: 2025/11/10 12:45:21 by aortigos ### ########.fr */
|
||||
/* Updated: 2025/11/10 20:43:06 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
Brain::Brain()
|
||||
{
|
||||
std::cout << "Brain has been created" << std::endl;
|
||||
int i = 0;
|
||||
while (i < 100)
|
||||
{
|
||||
ideas[i++] = "Empty idea";
|
||||
}
|
||||
}
|
||||
|
||||
Brain::~Brain()
|
||||
@@ -25,6 +30,7 @@ Brain::~Brain()
|
||||
Brain::Brain(const Brain &other)
|
||||
{
|
||||
std::cout << "Brain copied" << std::endl;
|
||||
*this = other;
|
||||
}
|
||||
|
||||
Brain& Brain::operator=(const Brain &other)
|
||||
@@ -32,7 +38,25 @@ Brain& Brain::operator=(const Brain &other)
|
||||
std::cout << "Brain copy assignment called" << std::endl;
|
||||
if (this != &other)
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
while (i < 100)
|
||||
{
|
||||
this->ideas[i] = other.ideas[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void Brain::setIdea(int i, const std::string &idea)
|
||||
{
|
||||
if (i >= 0 && i < 100)
|
||||
ideas[i] = idea;
|
||||
}
|
||||
|
||||
std::string Brain::getIdea(int i) const
|
||||
{
|
||||
if (i >= 0 && i < 100)
|
||||
return (this->ideas[i]);
|
||||
return ("Invalid idea");
|
||||
}
|
||||
Reference in New Issue
Block a user