Passed array inconsistent bahevior; C++ -


this question has answer here:

i'm trying learn basic c++ , moment started think got grasp of pointers stumbled across problem:

int sizeof(string texts[]) {     return sizeof(texts); }  int main() {     string texts[] = {"apple", "banana", "orange", "watermelon"};     cout << sizeof(texts) << endl;     cout << sizeof(texts) << endl; } 

and function returns

128 8 

my question is: happening when pass array argument? why c++ forgets array? have tried dereference inside method (return sizeof(*texts)) returned 32 instead size of 1 string element, not whole array. possible want do? mistaken?


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -