Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 19
Yes, an array of int is obviously different from an array of string. The size() method is on the string class, though. That's not a method on the array. Try this and you'll get size() as 5 which is obviously not the array's length: string s[]={"fooff","bar","baz"}; f(s); a->size() is like saying a[0].size().
7th Mar 2021, 7:19 PM
Josh Greig
Josh Greig - avatar
+ 13
When being passed into the function, the array decays to a pointer to the first element of the array. So actually, you are calling the size() method from the first string in the array, which just happens to have the same length as the array. If you replace "foo" by another string with a different length, e.g. "fo" or "fooo", you would get a different result.
7th Mar 2021, 7:20 PM
Shadow
Shadow - avatar
+ 4
I don't know much about cpp but is it about size() not defined in int ? string s[] { ... }; // s->size() may defined int i[] { ... }; // i->size() not defined i mead the size for integer what would be?
7th Mar 2021, 7:19 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
7th Mar 2021, 7:24 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 3
#define CPP ChillPill Arrays allow us to declare data elements of various types. Whereas all numeric data types' arrays are identical in operations & implementation, and the arrays with string data type are different. In C++, the string can be represented as an array of characters or using string class that is supported by C++.
9th Mar 2021, 3:08 AM
Anurag Kumar
Anurag Kumar - avatar
+ 2
but in fact what have the integer size to be if it defined ?
7th Mar 2021, 7:27 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 2
My opinion: <string *> is array of <string> (based on <char *> (8-bits)); <int *> is array of <int> (32-bits). <string> is a class, so it can have methods and arguments: it is very specialized data; <int> is just 32 bits which are the binary integer where the limit is 32 digits and, if needed, is filled with 0's at the left, where is there a space for method names and binary code?
8th Mar 2021, 8:10 AM
#0009e7 [get]
#0009e7 [get] - avatar
+ 2
Depends if you speak about data types ,then both are different .. indexes are the best option in both the cases for data access and retrieval.
9th Mar 2021, 6:15 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
Syaufina Khairunnisa hey this is not any messenger place this is for q/a discussion 😊😊😊 https://www.sololearn.com/discuss/1316935/?ref=app
9th Mar 2021, 12:45 PM
Anurag Kumar
Anurag Kumar - avatar
0
-
8th Mar 2021, 9:48 PM
return 0;
return 0; - avatar
0
Array contains intergers String contains characters
9th Mar 2021, 10:42 AM
Shravani Pandit
Shravani Pandit - avatar
0
Hi
9th Mar 2021, 12:33 PM
Syaufina Khairunnisa
Syaufina Khairunnisa - avatar