4
I’m trying to initialize a array with 0, however the compiler is generating error, I know I can initialize as well:
Constructor() : Value1(0), Value2(0), Initialized(false), vSh(false)
{
Name[100] = { 0 };
}
However, I believe that this would be a bad practice, I believe that there must be some other way to boot in the following way:
class Constructor
{
private:
char Name[100];
int Value1, Value2;
bool Initialized;
short vSh;
public:
Constructor() : Value1(0), Value2(0), Initialized(false), vSh(false), Name(0) {}
}
I could use string, but it’s not as fast compared to a char array, and I need to have an extremely fast program, any less millisecond makes a difference to my program.
– cYeR
Not always what seems fast is in fact. Even the greatest experts err in these assumptions. Who needs speed does not initialize limbs, especially long unless with real data. It also hardly creates a structure that wastes memory and harms cache, and perhaps creates overhead in use because it’s too big.
– Maniero
Why can’t you initialize limbs when you need speed, it gets in the way?
– cYeR
Of course, any operation takes time.
– Maniero
Even so, I believe that using string could be worse in the question of performance, thanks for replying my questions.
– cYeR