I am quite new to C++ so forgive me, if the mistake is stupid. I am currently working on a class, that can save single characters (only one of each) and do some simple operations. The problem I am having seems to be in the constructor of the class. Since I only have characters I am using a bool array of the size 256. So if I wanted to add the character "A" to my array I would simply flip array[64] to 1.
To use the array in the way I want to I initialized it with zeros for every index. So it looks like this:
Set<char>::Set() {
bool _elements[256] = {0};
}
If I check all the values of the member variable _elements now it does not only contain zeros. I don't know what might be causing this. There are no other function calls or anything in between.
Set set;
for (int i = 0; i < 256; i++) { printf("%dn", set._elemens[i]; }
Aucun commentaire:
Enregistrer un commentaire