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.