[C ++ Basics] confusing concepts: functions/array Pointers-pointer functions/arrays, classes/function templates-template classes/functions

Source: Internet
Author: User
Function pointer-pointer the focus of a function pointer is pointer. Indicates a pointer pointing to a function. Eg: int (* pf) (); the focus of pointer functions is functions. Indicates a function, and its return value is a pointer. Eg: int * fun (); array pointer-pointer array pointer focuses on pointer. Indicates a pointer pointing to an array. Eg: int (* pa) [8]; the focus of the pointer array is the array. Indicates an array, which contains a pointer. Eg: int * ap [8]; class template-template class template focuses on the template. A template is used to generate classes. Eg:
Template <typename T> class Vector {//...}; // Use this Vector template to generate many classes ), vector <int>, Vector <char>, Vector <int>, Vector <Shape *> ......
The focus of the template class is the class. Indicates the class generated by a template. Eg: vector <int>, vector <char>... function template-template function templates focus on templates. A template is used to generate functions. Eg:
Template <typename T> void fun (T ){//... }/* When used, you can explicitly produce template functions, such as fun <int>, fun <double>, and fun <Shape *> ....... You can also use the compiler to deduce template parameters during use to help you generate them implicitly (implicitly. Fun (6); // implicitly generate fun <int> fun (8.9); // implicitly generate fun <double> fun ('A '); // implicitly generate fun <char> Shape * ps = new Cirlcle; fun (ps); // implicitly generate fun <Shape *> */
The focus of template functions is on functions. Indicates a function generated by a template. Eg: fun <int> and fun <Shape *> generated by explicit or implicit (implicitly) above ...... All are template functions.
  • Class -------------- instance into ----------- object
  • Class template --------- convert an instance to ---------- template class
  • Function template ------- convert an instance to ---------- Template Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.