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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -