Introduction(简介)
For being a powerful object-oriented programming language, C++ is used almost everywhere including graphics and games section.
(C++作为一个强有力的面向对象语言,应用于包括图形、游戏等所有领域中。)

Complex features like multiple inheritance, template programming has made the language more powerful.
(向多重继承、泛型编程等特征使这门语言更加的强有力。)
So if you want to create powerful computer software or games, you should learn C++ properly and effectively.
(如果你想创造强有力的电脑软件和游戏,你应该正确高效的学习C++。)

To the novice programmer, C++ is always more complex and hard programming language than it actually is. I am saying this from my own experience. It is true that C++ is a complex featured programming language. But do not be afraid, once you have realized the importance of all the features of this language, you will feel the pleasure of learning this language.
(对于新手程序员,C++总是更加复杂和艰苦的编程语言,它实际就是这样。我从我自己的经验说这句话的。的确,C ++是一个复杂的功能的编程语言。但是不要害怕,一旦你已经意识到了这种语言的所有功能的重要性,你会觉得学习这门语言的乐趣。)

What IDE Should You Use to Write a C++ Program?
Well, if you are using Windows as your platform and looking for a C++ IDE, then I suggest the Microsoft Visual Studio. It has a fully-featured powerful C++ programming environment. Its various features such as the IntelliSense will help you to write programs more quickly and correctly. Its debugging system will let you correct your program. You will feel comfortable writing C++ program using this IDE.
(你应该使用什么样的IDE来写C ++程序?
这样,如果你使用的是Windows为平台,寻找一个C ++ IDE,那么我建议微软的Visual Studio。它有一个全功能强大的C++编程环境。它的各种功能,如智能感知将帮助您更快速,准确地编写程序。其调试系统将让你纠正你的程序。使用这个IDE编写C ++程序你会感到很舒服。)

How Can You Write a Good C++ Program?
A good program must be sufficiently easy to read, modify and extend. So your program should be easier to read by at least by yourself and there should not be any confusion when reading the program.
(你怎么能写一个好的C ++程序?
一个好的程序必须有足够的易阅性,可修改性和扩展性。所以,至少对于你自己来说,你的程序应该是更易于阅读,在读取程序时,不应该有任何混淆。)
If you are not be able to read your program easily, then how can you know whether yours program is going to work or not?
(如果你不能轻松的阅读自己的程序,你如何知道你的程序是否能正常工作呢?)

If any portion of your code is looking confusing or disturbing, your mind then deletes it and writes it again properly.
(如果你代码的任何部分看上去使人迷惑和令人不安,你的想法应该是立刻删除它,并且重新编写。)

C++ is a case-sensitive programming language. So always be careful about that.
(C ++是一种区分大小写的编程语言。所以,一定要加倍小心这一点。)
The following things will help you to improve readability of your program.
(接下来的事情将会帮助你提高你的程序的可阅读性。)

Variable Naming
(变量命名)

Use a deserving name for each variable of your program so that it will be easier for you to understand what purpose that variable was made for.
(为您的程序的每个变量使用一个值得的名称,这样它会更容易让你了解这个变量是为什么目的。)

Horrible variable naming can be also a great cause of program bug, at least for a novice programmer.
(至少对于一个新手程序员来说,恐怖的变量命名会引起程序很大的bug。)

int Money = 100;
const char* Name = "Shuvo";
printf("%s has only %d taka!\n", Name, Money);

Instead of:
(替换)

int Var1 = 100;
const char* Var2 = "Shuvo";
printf("%s has only %d taka!\n", Var2, Var1);
Use 'g_' or 'g' prefix for global variable and use 'm_' or 'm' prefix for member variable.

Use different prefix for each data-type such as ‘n’ or ‘i’ for integer variables, ‘f’ for floating type variables, ‘u’ for unsigned type, ‘p’ for any kind of pointers.
Use ‘str’ prefix for string type ( std::string ) variables.
(对于不同的变量类型,使用不同的前缀。比如说对于整形变量使用’n’或’i’,对于浮点型使用’f’,对于无符号类型使用’u’,对于各种类型的指针可以使用’p’。)

Use of data-type prefix will help you to figure out variables data-type, especially when your Code Editor does not support IntelliSense like feature.
(所有的数据类型的加前缀都会使你分清变量类型,尤其是你的编译器不支持智能推断。)

I am not saying that you must have to use those prefix and of course you can use your own variable name prefix that will help you much more than those prefixes.
(我不是说你必须使用这些前缀进行命名,你可以使用你自己的方式进行前缀命名。)

Function Naming
(函数命名)

Use a suitable name for each function of your program so that it will be easier for you to understand what intention the function was made for and what kind of job is doing the function.
(为您的程序的每个函数使用一个合适的名称,这样它会更容易让你明白为什么写这个函数,这个函数所做的工作是什么样子的。)

Use a different naming style for global and member functions that will help you to remember when you invoke the function. Although you can use the ‘::’ operator of C++ language for that purpose.
(对于全局函数和成员函数,使用不同的命名方式会帮助你记住合适调用这个函数。尽管在C++中你可以使用操作符::来显现类成员函数。)

Use of Comment
(使用注释)
Use comments at any place of your program where there is a possibility of confusion. It will help you remember which statement of your program is written for what purpose. It also helps when you later try to update your source code.
(在你的程序容易引起困惑的地方需要进行注释。这将会帮你记住你写此程序的意图。同样也会帮你记住你最后一次修改这段代码是什么时候。)

In C++, ‘// …..’ is used for single-line comment and ‘/* ….. */’ is used for multi-line comment.
(在C++中’// …..’ 用于单行注释,’/* ….. */’用于多行注释)

If you are working with several projects, I strongly suggest that you use enough comments inside each project source code.
(如果你的工作有几个工程,我强烈建议你在源代码中加入足够的注释。)

Keeping the Memory Free
(不要内存泄露)
This is the most painful task for a C++ programmer. Novice C++ programmer often forgets to deallocate the allocated memory and this makes a program buggy and memory cost.
(这是一个C ++程序员最痛苦的任务。初学C++程序员经常忘记释放分配的内存,这使得程序缺陷和存储成本。)

So do not let your program crash the user computer as well as your computer. Think more about memory management of your program.
(所以,不要让你的程序崩溃用户电脑,以及您的计算机。多想想你的程序的内存管理。)

When freeing a pointer, always check whether that pointer actually exists so that reduces program crash. You can do it in this way:
(当释放指针,请务必检查指针是否实际存在,这样减少了程序崩溃。你能做到这样:)

if ( ptr != NULL )
{delete ptr;ptr  = NULL;
}

Instead of:
(替换)

delete ptr;

Organize Your Project Source Code
(组织你的工程源代码)
If you are going to develop a big project that will need over thousand lines of source code, then do not gather all your source code into a single CPP source file. It will force your C++ compiler to compile the whole source-code even for every little modification.
(如果你要开发将需要超过千行源代码的大项目,那么就不要收集所有的源代码到一个单一的CPP源文件。它会迫使你的C ++编译器编译整个源代码,甚至对每个小的修改。)

Divide your source code into several CPP source and header files. This will let your compiler compile only those source files that you have modified. So it will save your time.
(把你的源代码为几个CPP源文件和头文件。这将让你的编译器编译只已修改的源文件。因此,这将节省您的时间。)

Simple Tips on C++(对于C++的一些建议)相关推荐

  1. 10 simple Tips to Avoid Violating Google Adsense TOS Read more: 10 simple Tips to avoid violating G

    http://www.shoutmeloud.com/10-simple-mistake-which-violate-google-adsense-policies-and-get-banned.ht ...

  2. 程序员如何提高编程时打字速度的5个Tips

    文章目录 程序员如何提高编程时打字速度 前言 打字速度等级 测试编程时打字速度 提高编程时打字速度的5个Tips Tips1: 选用合适的键盘 Tips2: 保持正确的坐姿和打字姿势 Tips3: 选 ...

  3. Reading Club Questions Feedback

    Reading Club Questions Feedback 文章目录 Reading Club Questions Feedback Paper 1 Title Keywords (Domain) ...

  4. reloaddata 跳动_纸跳动像素

    reloaddata 跳动 I would like to open with a problem. 我想开一个问题. Why are so many designer going straight ...

  5. 什么样的代码是好代码_什么是好代码?

    什么样的代码是好代码 编码最佳实践 (Coding Best-Practices) In the following section, I will introduce the topic at ha ...

  6. 数据暑假实习面试_面试数据科学实习如何准备

    数据暑假实习面试 Unfortunately, on this occasion, your application was not successful, and we have appointed ...

  7. 机器学习工程师 - Udacity 项目:实现一个狗品种识别算法App

    步骤 0: 导入数据集 导入狗数据集 在下方的代码单元(cell)中,我们导入了一个狗图像的数据集.我们使用 scikit-learn 库中的 load_files 函数来获取一些变量: train_ ...

  8. python pip、conda、windows CMD常用命令大全!

    文章目录 python pip 常用命令 1.查找软件 2.安装软件 3.更新软件 4.卸载软件 5.列出已安装软件 6.查看一个软件包时安装了哪些文件 7.命令补全 8.升级所有包 9.修改pip安 ...

  9. windows调整窗口大小_175 Windows 7调整,提示和操作方法文章

    windows调整窗口大小 Windows 7 is being officially released on October 22nd, which also happens to be today ...

  10. 如何在不泄露私人信息的情况下共享屏幕

    Stockbakery/Shutterstock面包店/快门 New to the world of working remotely? Minimize your chances of embarr ...

最新文章

  1. UIMenuController的使用,对UILabel拷贝以及定制菜单
  2. NeHe教程Qt实现——lesson02
  3. python爬虫,记录一下爬取过程,列表数据,翻页,post方式,保存字典
  4. 电气:蒙特卡洛1000个风光场景并通过削减法|聚类法得到几个典型场景(matlab\python实现)
  5. java socket 传送进度_java-★-Socket文件上传/进度条
  6. linux系统子接口配置文件,Linux网卡绑定、子接口-IP别名
  7. C4D合集灵感|时尚潮流色彩、搭配梦幻C4D元素设计
  8. javaScript技巧表:单提交验证类[转载]
  9. Bailian3708 1的个数【进制】
  10. pch文件找不到的解决办法
  11. 查找与清除线程插入式木马
  12. WIN7 X64 解决无法安装IE11,以及无法点击微软升级包MSU的问题
  13. 小米手机与计算机如何连接网络连接,小米手机如何连接电脑?如何传输文件至电脑?...
  14. 手机更新显示itunes store无法连接服务器,iPhone无法连接App Store、iTunes Store?解决方法有哪些?...
  15. 094 chrome浏览页面常用快捷键
  16. Stacked Attention Networks for Image Question Answering(用于图像问答的堆叠注意力网络)
  17. 人机博弈小游戏(Java)
  18. r5 5500u和r5 5600u的区别 哪个好
  19. (附源码)ssm产品裂变管理系统 毕业设计 100953
  20. iOS-CocoaPods

热门文章

  1. 恢复ubuntu20.04默认桌面管理器
  2. 25个令人难忘的广告设计
  3. Node 的 cross-env 模块
  4. 基于15单片机通过ESP8266实现远程浇花系统(支持天猫精灵和小爱同学)
  5. hp打印机一直显示正在打印中_打印机显示正在打印却没反应 - 卡饭网
  6. 学大数据需要具备四种条件?你具备几种?
  7. 人脸识别活体检测sdk 百度 python_Python百度人脸识别SDK的使用
  8. 《算法竞赛进阶指南》0x62 T4 黑暗城堡
  9. java模拟手机号码发短信_java实现发送手机短信
  10. Redis的复制(Master/Slaver)