Structs Flashcards
What is needed for making a class task?
We need a default constructor, copy constructor, = operator :
What do i need to be careful of when solving structures?
When making a function to find some min, max to make sure that that the indexes of the array are set properly e.g.:
if i have an array that i want to access from a different structure through the parameter struct that i have in my function i should call inside the loop the second loop ājā which accesses the elements of the second struct that im accessing from the initial parameter struct:
for (int i = 0; i < size; ++i) {
for (int j = 0; j < s[i].n; ++j) {
if (s[i].available[j].touch == 1) {
touchScreen = true;
if (s[i].available[j].price < min) {
min = s[i].available[j].price;
index = i;
}
}
}
}