I have some homework to do but these pointers are confusing me a lot. So I have this code under:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int funct(list *l41){
int total=0;
list *current = l41 -> next;
while (current){
cout << "third: " << current -> third << endl;
cout << "forth : " << current -> forth << endl;
cout << "fifth : " << current -> fifth << endl;
cout << "sixth : " << current -> sixth << endl;
cout << "sevent : " << current -> sevent << endl;
cout << "---------------------" << endl;
current = current -> next;
total += 41 % 10 + 1;
};
return total;
};
Now here is the question: How much storage space in working memory holds the pointer current (defined within a function funct)?
My personal opinion is that the pointer current is int type, so that means that the answer is 4 bytes. My friend on the other hand thinks that the pointer is type list.
What's the answer now?
My personal opinion is that the pointer current is int type
I see how you're thinking. It's very similar to an int, but it's not an int. It is, as Peter says, an object of type pointer-to-a-list. It will almost certainly be the same size as an int, but it is not an int.
current is definitely not an object of type list. It points to a list, but it's not the list.