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().
+ 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.
+ 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?
+ 3
ohh 😅 #define CPP ChillPill
+ 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++.
+ 2
but in fact what have the integer size to be if it defined ?
+ 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?
+ 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.
+ 1
Syaufina Khairunnisa hey this is not any messenger place this is for q/a discussion 😊😊😊
https://www.sololearn.com/discuss/1316935/?ref=app
0
-
0
Array contains intergers
String contains characters
0
Hi