Is string [] not a type?

The user sent a response saying:

So, take Hashthe link

void topWords(Hash const& t, std::string const& word, std::string* topA); 

Besides,

  • string[] not a type in C ++
  • ...

The original function sent by the questionnaire looks like this:

void topWords(Hash t, string word, string topA[]); 

I know that in Java the syntax for declaring an array is:

int[] anArray;

whereas in C ++ this is:

int anArray[someNumber];

I suspect this refers to the defendant, but perhaps they meant something else. So I consulted with n3337 :

formatting note: unnecessary things are omitted, new lines are added for readability

§ 8.3.4 [dcl.array]

1 In the ad T D, where it Dhas the form

D1 [constant expression opt ] Attribute specifier-cl <sub> non-automatic sub>

T D1 "-declarator-type-list T", of D - ;

...

T ;

...

(5.19), . ( ) . N, N 0 N-1, D "----" N T ".

...

, , , D " array-declarator-type-list-array T ", . " array-type-list-type-list-type-list-type-type-list-type-type-type-type-type-type-type-type "array-declarator-type-list-array" T ", . 3.9.

...

anArray someNumber int. topA pointer to std::string. ?


, . , , . Java vs ++ , , string[] .

§3.9/6:

... , , ; ( " T" " N T" ) - ... [ :

extern int arr[]; // the type of array is incomplete

, arr .

+4
5

, , - topA , array of T pointer to T. , anArray someNumber ints.

, , ++ , . extern, :

extern int anArray[];

... anArray int, , .

- , : string topA[], , string *topA, , , : std::vector<std::string> &topA ( std::vector<std::string> const &topA, ).

+4

string[] - .

:

++ 11 §3.9/6:
" ; (" T "" N T") - .

extern int x[];

,

int x[42];

- , - .

struct Blah;
extern Blah x[42];

auto main() -> int {}

void.


, , , unique_ptr<T> unique_ptr<T[]>. , . , T, T_base T_derived, , , , ( ).

+4

§8.3.4, ( ):

N T. "array-type-list-type-list-list-N-type - ---- T", . 3.9. "cv-qualifier-seq array of N T" "array" N cv-qualifier-seq T ", " T "" T ". --seq .

:

typedef int A[5], AA[2][3];
typedef const A CA; // type is "array of 5 const int"

, , , , , , , . , , , . " T", string[].

+2
extern int arr[]; // the type of array is incomplete

, arr .

arr . int[] . arr , (, TU).

[...] D - "--- T",

arr (, sizeof), .

+2

string[] - , ; string[]s , , . , , string *.

string, , std::vector<std::string> ( ) boost::shared_array<std::string> ( ) . boost::shared_array, , , Java.

0

All Articles