Get the App
SLTechnology News&Howtos  ›  Development  › 

What if the function definition cannot be matched to an existing declaration

Shulou Source: shulou.com Published: 2022-06-03 05:43:08 09月17日 Update

This article mainly introduces how to match the function definition with the existing declaration. The introduction in this article is very detailed and has certain reference value. Interested friends must read it!

In the whole MFC, the following problems were encountered.

d:\My documents\visual studio 2008\projects\virtuosc\arraylisttype.h (171) : error C2244:

'arrayListType::maxListSize': Cannot match function definition to existing declaration

1> d:\My Documents\visual studio 2008\projects\virtuosc\arraylisttype.h (37) : See

Declaration of "arrayListType::maxListSize"

1> Definition

1> 'int arrayListType::maxListSize(void)'

1> Existing claims

1> 'int arrayListType::maxListSize(void)'

Think for a long time have not been able to solve, and later in Baidu's help to solve. The problem was actually very easy to solve. It was just that he did not expect it, but he had no choice. He did not expect it to be unexpected. Write down the problem now, and the next time it comes up, it can be solved quickly. The solution is as follows:

Before arraylisttype.h, insert:

#ifndef ARRAYLISTTYPE_H

#define ARRAYLISTTYPE_H

At the end of arraylisttype.h insert:

#endif

This way the header file arraylisttype.h will not be duplicated and cause compilation errors. Now explain the above statement.

#ifndef ARRAYLISTTYPE_H means "if macro ARRAYLISTTYPE_H is not defined"

#define ARRAYLSTTYPE_H means "define macro ARRAYLSTTYPE_H"

#endif means "end"

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

Write your own header file later. Be sure to add the above preprocessing command

That's all for "What if I can't match a function definition to an existing declaration?" Thanks for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Questions functions unexpected meaning files statements compilation what to do content that is documents logos identifiers articles facets help generally speaking between code value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info Microsoft vpn MySQL