Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

区分C和C++? #1670

Closed
cmpute opened this issue Sep 4, 2019 · 16 comments
Closed

区分C和C++? #1670

cmpute opened this issue Sep 4, 2019 · 16 comments
Labels
Discussion / 需要讨论 Further discussion is welcome

Comments

@cmpute
Copy link
Contributor

cmpute commented Sep 4, 2019

想问下C语言在文档里的定位是啥?是和C++合并到一块,还是可以专门写个页面?C和C++还是有一定区别的

@Ir1d
Copy link
Member

Ir1d commented Sep 5, 2019

我觉得可以开个页面讲讲区别🤔

@ouuan
Copy link
Member

ouuan commented Sep 5, 2019

(我觉得不需要专门讲 C)

@Ir1d
Copy link
Member

Ir1d commented Sep 5, 2019

同时似乎也没什么理由不专门讲 C

@ouuan
Copy link
Member

ouuan commented Sep 5, 2019

绝大部分 OIer 都用 C++,没必要讲 C。

@ouuan
Copy link
Member

ouuan commented Sep 5, 2019

*绝大部分 OIer 都用 C with STL with iostream with (还有啥一下想不全了)

@Ir1d
Copy link
Member

Ir1d commented Sep 5, 2019

绝大部分 OIer 不用的东西多着去了(比如 wsl,testlib,latex 等等),为什么别的讲了,C 不能讲呢 🤔
我觉得如果有人愿意写的话,没什么理由拒绝这部分内容

@ouuan
Copy link
Member

ouuan commented Sep 5, 2019

我觉得 testlib 和 latex 只是部分 OIer 不用的东西吧(不知道有没有大部分)

如果刚入门的也算,那应该是大部分了。

@ouuan
Copy link
Member

ouuan commented Sep 5, 2019

“如果有人愿意写的话,没什么理由拒绝这部分内容” 和我的论点不冲突,在当前不会对 Wiki 造成影响,我可以看做没有这句话吗(

@Ir1d
Copy link
Member

Ir1d commented Sep 5, 2019

fine,我理解楼主是想问要不要讲讲区别,我的观点是可以,你说不需要,如果这没什么冲突的话倒也挺好

@ouuan
Copy link
Member

ouuan commented Sep 5, 2019

(那我重新表述一下我的观点吧)

可以但没必要专门写个页面讲 C 和 C++ 的区别。

在其它页面不要太过区分 C 和 C++。

@abc1763613206 abc1763613206 added the Discussion / 需要讨论 Further discussion is welcome label Sep 5, 2019
@cmpute
Copy link
Contributor Author

cmpute commented Sep 5, 2019

我其实是这么想的,可以做一页讲一下主要的区别和陷阱(如new和free混用)。类似于“Pascal 急救转 C++ ”的页面定位。
就是因为很多 OIer 写的都是C/C++的杂合体,导致很多人以后继续使用C++时写出来的代码奇丑无比= =,所以我觉得至少明确区分一下C和C++对代码的健壮性是由好处的。
另外我同意其他页面不要太区分C/C++,并且推荐以C++语法为基准。

@cmpute
Copy link
Contributor Author

cmpute commented Sep 5, 2019

我在我的PR里一块加了吧

@Enter-tainer
Copy link
Member

我其实是这么想的,可以做一页讲一下主要的区别和陷阱(如new和free混用)。类似于“Pascal 急救转 C++ ”的页面定位。
就是因为很多 OIer 写的都是C/C++的杂合体,导致很多人以后继续使用C++时写出来的代码奇丑无比= =,所以我觉得至少明确区分一下C和C++对代码的健壮性是由好处的。
另外我同意其他页面不要太区分C/C++,并且推荐以C++语法为基准。

说句题外话x,关于 new 和 free 的问题,我自己在写一些动态开点的数据结构的时候好像从来没 free 过内存(大雾)(把锅甩给操作系统)

另外,可以详细说一下 “new 和 free 混用的” 的问题吗?

@cmpute
Copy link
Contributor Author

cmpute commented Sep 5, 2019

@Enter-tainer new和free混用可能会导致内存泄漏,我记得好像是用new int[10]这样的语法弄出来的数组用free就清不干净。不过确实在OI的时候没人会free,毕竟只跑一次x
但是介绍一下还是有好处的

@Enter-tainer
Copy link
Member

想了下好像应该配套使用的是 new 和 delete?(记不到了,毕竟用的少)

@cmpute
Copy link
Contributor Author

cmpute commented Sep 5, 2019

是的,new用delete,malloc用free

@ouuan ouuan closed this as completed in 986d8b4 Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion / 需要讨论 Further discussion is welcome
Projects
None yet
Development

No branches or pull requests

5 participants