#Using Structs and Constructors

6 messages · Page 1 of 1 (latest)

snow inletBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

alpine ocean
#

main.cpp ```cpp
#include <iostream>
#include <string>
#include <string_view>
#include "Monsters.cpp"

int main()
{
// MonsterS is the struct dragon is the name, its Init with MonsterType::dragon
// the constructor provides the values for hp, attack, armor

MonsterS dragon{ MonsterType::Dragon };

std::cout << dragon.PrintMonsterName(MonsterType::Dragon);

}```

viral prism
#

What's the question? thinkies

alpine ocean
#

so my question is when i make the MonsterS object in main then provide it with the MonsterType::Dragon, does this make a copy of the whole struct and all its content or just the infomation for Dragon, and if i make another object MonsterS goblin would the then copy the whole struct again

#

it seems like a lot of data, i know passing by refences avoids a copy, should i just make one Monters Object and use that?