当前位置:网站首页>[C / C + + 1] clion configuration and running C language
[C / C + + 1] clion configuration and running C language
2020-11-06 01:22:10 【Elementary school students in IT field】
List of articles
One 、Clion To configure
1.1 brief introduction
1.1.1 Clion idea
CLion yes Jetbrains The company's new product is for development C/C++ Designed cross platform IDE, It is a IntelliJ Designed for the foundation , It also includes many intelligent functions to improve the productivity of developers .
Also supports python Oh , Believed to have been used IntelliJ idea Developed java My friends are very clear about this IDE A powerful , So as Jetbrains Flag c/c++ development tool CLion It also includes many intelligent functions to improve the productivity of developers , Improve developer productivity .
Clion Code style and other configuration are the same Jetbrains Related software , I won't go into details here .
1.1.2 C And C++ The difference between ; The difference between process oriented and object-oriented
- C++ It's object-oriented (object oriented programming—OOP). Emphasize the object , The object performs the action .
- C It's process oriented (procedure oriented programming—POP). Emphasis on the process of implementation .
summary : Object oriented is the first abstraction of various objects ( All kinds of ), Encapsulating data and methods in objects ( class ), Then the objects interact with each other .
Process oriented is the decomposition of a problem into several steps ( action ), Every step ( action ) With a function , In use , Passing data to these functions .
- A typical example : Put the elephant in the refrigerator .
C++ That's what it does : Two objects are involved : Refrigerator and elephant . Three actions : Open the refrigerator , Place the elephant , Close the refrigerator .
First define a refrigerator class , He has a way to open it , Placement method , How to close . And then define an elephant . Next, build the object of the refrigerator and the elephant , Then the refrigerator object calls the method to open the door , The refrigerator object calls the method of placing the elephant object , Finally, the refrigerator object is closed .
Fridge{
open();lay();close();}// There are three ways for the refrigerator class
main()
{
Elephant elephant;// Building an elephant object
Fridge fridge;// Construct a refrigerator object
fridge.open();
fridge.lay(elephant);
fridge.close();
}
And when C That's what it does : First open the refrigerator door , Then put the elephant in , Finally close the refrigerator door .
main()
{
open();
lay(elephant);
close();
}
Another typical example : It's raining , People open umbrellas :
C++ That's what it does : Three objects are involved : rain , people , The umbrella . Two actions : It's raining , Man opens his umbrella .
First, three objects , That is to define three classes . Rain object Rain, It has a way to rain fall(); Human object Person, He has a way to open it open(); Umbrella object Umbrella;
Rain
{
fall();
}
Person
{
open();
}
main()
{
Rain rain;
Person person;
Umbrella umbrella;
rain.fall();
person.open(umbrella);
}
and C That's what it does :
Process oriented : It's raining , People open umbrellas :
main()
{
rain();
open(umbrella);
}
1.2 To configure c
my mac The computer has been installed c 了 , So I won't download it , If there is no download, please refer to the operation below .
Default has generated main.c, But we can't run , Because we still lack the compiler environment , Click on Setting Open Settings , Search for Toolchains, We found that clion There are so many kinds of environments for us MinGW,CygWin,Visual studio etc. , What I choose here is MinGw, Click the right side. download, Download and run the installation , And then in Enviroment Choose... On the right mingw-w64 The position of , Here's the picture :
1.3 Select the corresponding c/c++
c++ choice executable
c choice cxecutable
1.4 Create your own c++
If we can create our own c/c++ file , Pictured :
C Language choice .c,C++ choice .cpp!
1.5 Clion Generate multiple executable files in
Building a new Clion During the project , Will automatically generate a folder cmake-build-debug, It can help us deal with the whole thing quickly C++ The project is compiled and run . The executable file generated after the main function is compiled is located in cmake-build-debug Under the folder .
If we need to be in a C++ If you build multiple main functions and generate multiple executable files in the project , We need to be right CMakeLists.txt Make changes . The specific steps are as follows :
(1) If we create two main function files , Respectively main.cpp and main2.cpp.
(2) Creating the first main.cpp after , Suppose that CMakeList.txt It looks like this :add_executable(MAIN main.cpp).
(3) Create a second main2.cpp When , Need to choose target, If you choose the first main.cpp, So in CMakeList.txt There will be add_executable(MAIN main.cpp main2.cpp), However, it is impossible to meet our needs .
(4) So we need to change it to add_executable(MAIN main.cpp) and add_executable(MAIN2 main.cpp) You can build two executables .
(5) stay Clion When used in , In the upper right corner of the software, you can choose which main function file to compile , Or the whole project main Functions are compiled
Personal operation case :
Now I main.cpp yes c Program , I run mian.cpp ,
1. stay cmakelists.txt in add_executable Modify the corresponding .cpp File can
2. Be sure to recompile your project .
3. If you run map1.cpp file Only need to cmakelists.txt in add_executable modify .cpp File can
add_executable(map map1.cpp)
版权声明
本文为[Elementary school students in IT field]所创,转载请带上原文链接,感谢
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World