当前位置:网站首页>New knowledge in big homework
New knowledge in big homework
2022-07-26 04:48:00 【Ruijing_ reiki】
C++ Final assignment —— Make a small world
As the builder of the program , I found some problems when writing the framework and adding , And make the following partial solutions .
1、 Use of multiple inheritance
At the beginning, I hope the program can show the characteristics of simplicity , According to the knowledge learned at that time, we finally adopted the method of multiple documents . And when there is no learning inheritance , When I finish compiling some programs of the two classes and prepare for debugging , Find out if main Function is also created Player Class objects and Study Class object , Because attributes exist in various objects , Finally, it is inconvenient to summarize , So I found the method of inheritance . Inheritance can ensure that there is only one object in the whole program , Only the attribute of this object changes . However, there are three classes in this program , Want to make main Only exists in the function Player Class object , You need to let him inherit two classes , Through learning, I learned the mode of multiple inheritance , I found no problem after trying .
2、 Redefining problems ( See the previous blog for details )
The second problem is to find that when I attach several files with inheritance , The program will report an error , Error name has [Error] previous definition of 'class XXX' as well as [Error] redefinition of 'class XXX', And that is [Error]expected class-name before '{' token, Later, I searched the Internet , It is found that there is a problem of redefinition . Finally, add #ifndef _ Class name _H and #define _ Class name _H, Tail add #endif, According to the information I searched , It roughly means when this macro (define The following identifier ) When it hasn't been defined yet , The preprocessor will insert the contents of the header file , When this macro appears again in the future ifndef Judgment for false, The contents of this header file will not be inserted , That is to avoid redefinition .
3、 How to jump out of multiple cycles
Help fill in 1 In the end , At first, I hope to use break Out of the loop , But because the program is a nested loop , You can only jump one level . So set a global variable , When this ending is triggered, the value of the global variable changes . Set a condition in the outer loop , If the value of the global variable changes, it will jump out of the outer loop . But no matter how you try, the system will automatically trigger the outer layer break, The game went through a month . Finally, when I check the information on the Internet , Found the existence of labels . Finally, I added goto sentence , stay main A label is added at the end of the function , Make this ending jump out of the double-layer cycle at one time , And skip the ending , End the program directly .
4、 similar “ Change the scene ” How to change the page
When I saw the students' very simple pictures in class, I liked them very much , At first, our program didn't have the function of clearing the screen , So the whole program is very lengthy . After class, I checked the relevant information on Friday evening , Used system(“cls”); Statement to clear the previous program . Choose the right time to clear the screen according to the program content . For example, basic options one, two, three , If you choose 1, Go to the classroom , At this time, clear the screen , eject “ Arrive at the classroom ” Words , And then create a sense of the scene when you really arrive in the classroom .
( Digression :
It should have been written last month , I felt it , I didn't write an article last month, mainly because of the exam + Big homework is too busy
Because the big homework is the result of the Group , No source code , What you want can be sent by private mail ( Although the things made are not very interesting
This blog is extracted from the report , There may be suspicion that the context is not smooth , Please understand
Please correct me if there is any mistake , Be deeply grateful
)
边栏推荐
- Niuke-top101-bm32
- minipcie接口CAN卡解决工控机扩展CAN通道的难题 minipcie CAN
- Sliding window -- leetcode solution
- Add watermark to ffmpeg video
- 2022杭电多校第二场 A.Static Query on Tree(树剖)
- NFT的几种发行方式你都了解过吗?不同的发行方式有什么优缺点?
- C语言——指针一点通※
- [300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (VIII)
- C language - pointer one touch ※
- 擅长C(暑假每日一题 6)
猜你喜欢

Two ways to create MySQL database

UE4 靠近物体时显示文字,远离时文字消失

"Game engine light in light out" 4. shader

Wsl2 best practices, eliminate difficult xshell and finalshell

Kubernetes advanced training camp scheduler

Build a maker Education Laboratory for teenagers

User defined type details

vector详解和迭代器失效问题

minipcie接口CAN卡解决工控机扩展CAN通道的难题 minipcie CAN

Database startup message: ora-29702: error occurred in cluster group service
随机推荐
Use field parameters for report translation
Codeforces Round #807 (Div. 2)
Steam science education endows classroom teaching with creativity
2022 Henan Mengxin League game (3): Henan University J - magic number
嵌入式实操----基于RT1170 FreeRTOS实现CPU使用率统计(二十四)
FFmpeg 视频添加水印
Swiftui one day crash
C language - pointer one touch ※
QT compilation error sorting and remote module Download
Weights & biases (II)
Keil V5 installation and use
2022 Henan Mengxin League game (3): Henan University B - reverse pair count
2022杭电多校 DOS Card(线段树)
Wsl2 best practices, eliminate difficult xshell and finalshell
三、@RequestMapping注解
minipcie接口CAN卡解决工控机扩展CAN通道的难题 minipcie CAN
autocomplete禁止表单自动填充
Compiled by egg serialize JS
User defined type details
3、 @requestmapping annotation