What is the difference between Type** name, and Type* name[]?
Why would someone use one over the other?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well that depends, is it in a variable declaration or in a function argument? If in a variable declaration:
The first one is a pointer to pointer to type, while the second one is an array of pointers to type of length 3.
If in a function argument, they are the same thing. Arrays decay to pointers, and both
Type** nameandType* name[]are exactly the same as function arguments. However, the second form makes it clear that name is an array of pointers of unknown length, while the first one does not. I would useType**to specify a single element andType*[]to specify an array.