Solution to the problem that function definitions cannot match existing declarations

Source: Internet
Author: User

We encountered the following problems during the entire MFC tonight.

D: \ My Documents \ visual studio 2008 \ projects \ virtualosc \ arraylisttype. h (171): error C2244:
"ArrayListType <elemType>: maxListSize": the function definition cannot match the existing declaration.
1> d: \ My Documents \ visual studio 2008 \ projects \ virtualosc \ arraylisttype. h (37): see
"ArrayListType <elemType>: maxListSize" Statement
1> Definition
1> 'int arrayListType: maxListSize (void )'
1> existing statement
1> 'int arrayListType <elemType>: maxListSize (void )'

After thinking for a long time, I failed to solve the problem. Later I solved it with the help of Baidu. The problem is actually a good solution, but I did not expect it, but there is no way, I did not expect it. Now we can record the problem and solve it quickly when this problem occurs again. The solution is as follows:

Add the following before arraylisttype. h:

# Ifndef ARRAYLISTTYPE_H
# Define ARRAYLISTTYPE_H

Add the following content to the end of arraylisttype. h:

# Endif

In this way, the header file arraylisttype. h will not be repeatedly included, leading to compilation errors. Now, explain the preceding statement.


# Ifndef ARRAYLISTTYPE_H indicates "if the macro ARRAYLISTTYPE_H is not specified"

# Define ARRAYLISTTYPE_H indicates "define macro ARRAYLISTTYPE_H"

# Endif means "end"

In general, if the identifier ARRAYLISTTYPE_H is not defined, define the identifier ARRAYLISTTYPE_H and compile the code between # ifndef and # endif. If the header file ARRAYLISTTYPE_H is included for the second time, the statement # ifndef becomes invalid and all the statements before # endif are ignored by the compiler. ---- Data Structure Using C ++, D. S. Malik

Before writing the header file, remember to add the preceding preprocessing command.

Related Article

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.