CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Brain クラス

Represents the brain of an animal, holding a collection of ideas. [詳解]

#include <Brain.hpp>

Brain 連携図
Collaboration graph

公開メンバ関数

 Brain ()
 Default constructor for Brain. Initializes all 100 ideas to "Thinking...". Displays a construction message.
 
 Brain (const Brain &other)
 Copy constructor for Brain. Performs a deep copy of all ideas from another Brain object. Displays a copy construction message.
 
Brainoperator= (const Brain &other)
 Copy assignment operator for Brain. Performs a deep copy of all ideas from another Brain object. Handles self-assignment to prevent issues. Displays a copy assignment message.
 
 ~Brain ()
 Destructor for Brain. Displays a destruction message. No dynamic memory to free directly within Brain itself, as ideas is a fixed-size array of std::string.
 
void setIdea (int index, const std::string &idea)
 Sets an idea at a specific index in the brain. Performs bounds checking to ensure the index is valid (0-99).
 
const std::stringgetIdea (int index) const
 Gets an idea from a specific index in the brain. Performs bounds checking. If the index is out of bounds, an empty string is returned.
 
 Brain ()
 
 Brain (const Brain &other)
 
Brainoperator= (const Brain &other)
 
 ~Brain ()
 
void setIdea (int index, const std::string &idea)
 
const std::stringgetIdea (int index) const
 

詳解

Represents the brain of an animal, holding a collection of ideas.

The Brain class manages an array of 100 std::string objects, conceptually representing the animal's thoughts. It is designed to support deep copying, ensuring that when a Brain object is copied, its entire set of ideas is duplicated, not just referenced.

Brain.hpp37 行目に定義があります。

構築子と解体子

◆ Brain() [1/4]

Brain::Brain ( )

Default constructor for Brain. Initializes all 100 ideas to "Thinking...". Displays a construction message.

Brain.cpp29 行目に定義があります。

◆ Brain() [2/4]

Brain::Brain ( const Brain other)

Copy constructor for Brain. Performs a deep copy of all ideas from another Brain object. Displays a copy construction message.

引数
otherThe Brain object to copy from.

Brain.cpp42 行目に定義があります。

◆ ~Brain() [1/2]

Brain::~Brain ( )

Destructor for Brain. Displays a destruction message. No dynamic memory to free directly within Brain itself, as ideas is a fixed-size array of std::string.

Brain.cpp72 行目に定義があります。

◆ Brain() [3/4]

Brain::Brain ( )

◆ Brain() [4/4]

Brain::Brain ( const Brain other)

◆ ~Brain() [2/2]

Brain::~Brain ( )

関数詳解

◆ getIdea() [1/2]

const std::string & Brain::getIdea ( int  index) const

Gets an idea from a specific index in the brain. Performs bounds checking. If the index is out of bounds, an empty string is returned.

引数
indexThe index from which to retrieve the idea.
戻り値
A const reference to the idea string at the given index, or an empty string if out of bounds.

Brain.cpp92 行目に定義があります。

◆ getIdea() [2/2]

const std::string & Brain::getIdea ( int  index) const

◆ operator=() [1/2]

Brain & Brain::operator= ( const Brain other)

Copy assignment operator for Brain. Performs a deep copy of all ideas from another Brain object. Handles self-assignment to prevent issues. Displays a copy assignment message.

引数
otherThe Brain object to assign from.
戻り値
A reference to the assigned Brain object.

Brain.cpp57 行目に定義があります。

◆ operator=() [2/2]

Brain & Brain::operator= ( const Brain other)

◆ setIdea() [1/2]

void Brain::setIdea ( int  index,
const std::string idea 
)

Sets an idea at a specific index in the brain. Performs bounds checking to ensure the index is valid (0-99).

引数
indexThe index at which to set the idea.
ideaThe string value of the idea.

Brain.cpp80 行目に定義があります。

◆ setIdea() [2/2]

void Brain::setIdea ( int  index,
const std::string idea 
)

このクラス詳解は次のファイルから抽出されました: