| |

VerySource

 Forgot password?
 Register
Search
View: 866|Reply: 2

How to create a header file to show the code "#if !defined(AFX_PLANE...."?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-28 18:00:01
| Show all posts |Read mode
How can these codes appear on the header file?
#if !defined(AFX_PLANE_H__B446A8BD_83A8_489F_9874_9612567D1A37__INCLUDED_)
#define AFX_PLANE_H__B446A8BD_83A8_489F_9874_9612567D1A37__INCLUDED_
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-9-28 22:15:01
| Show all posts
This is automatically added by MFC, you can add it yourself
#if !define AAA
#define AAA

#endif
Reply

Use magic Report

2

Threads

20

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-9-29 02:30:01
| Show all posts
First of all, we must clarify the meaning of adding these two lines of code
It is to avoid duplication of function definitions caused when the header file is included multiple times
If you use VC to automatically add classes, the system will automatically generate these codes
If you write the header file yourself, adding one yourself will have the same effect
For example, add in test.h
#ifndef TEST_H
#define TEST_H
.....
#endif
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list