C ++指南 [英] C++ Guidelines

查看:65
本文介绍了C ++指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计,


我想知道是否有汇编的C ++指南

。以下是我到目前为止所收集的一些内容(例如):


- 功能应该放在一个屏幕上,来自不同的来源。

- 非叶类应该是抽象的(有纯虚方法),来自

更有效的C ++,第33项。


- 虚拟默认情况下,方法应该是私有的,如果它们需要访问基类的版本(除了析构函数,

课程),从 http://www.gotw.ca/publications/mill18.htm


- 头文件应该是自包含的,来自各种来源。


- 基类的析构函数应该是虚拟的或受保护的。


我想我可能已经错过了(或者从未听说过)更多的东西。

任何人都知道在哪里可以找到这样的东西?或者有一些指南

他们自己分享?


- Pete

Hi Folks,

I''m wondering if there is a compilation of C++ guidelines out there
anywhere. Here are some of the ones I''ve picked up so far (as examples):

- Functions should fit on one screen, from various sources.

- Non-leaf classes should be abstract (have pure virtual methods), from
More Effective C++, Item 33.

- Virtual methods should be private by default and protected if they
need access to a base classes version (except for the destructor, of
course), from http://www.gotw.ca/publications/mill18.htm.

- Header files should be self contained, from various sources.

- Destructors for base classes should be either virtual or protected.

I think I''ve probably missed (or never heard of) quite a few more.
Anyone know where I can find such things? Or have some guidelines of
their own to share?

-- Pete

推荐答案

Pete Vidler< pv ***** @ mailblocks.com>写道:
Pete Vidler <pv*****@mailblocks.com> wrote:
我想知道是否有汇编的C ++指南在任何地方。以下是我到目前为止所收到的一些内容(例如):

- 功能应该放在一个屏幕上,来自不同的来源。

- 非 - 叶子类应该是抽象的(有纯虚方法),来自更有效的C ++,第33项。

- 虚拟方法默认应该是私有的,如果它们需要访问则受到保护从 http://www.gotw.ca/publications/mill18.htm

- 头文件应该是自包含的,来自各种来源。

- 基类的析构函数应该是虚拟的或受保护的。

我想我可能已经错过了(或者从未听说过)更多。
任何人都知道我在哪里可以找到这样的事情呢?或者有一些自己要分享的指南?
I''m wondering if there is a compilation of C++ guidelines out there
anywhere. Here are some of the ones I''ve picked up so far (as examples):

- Functions should fit on one screen, from various sources.

- Non-leaf classes should be abstract (have pure virtual methods), from
More Effective C++, Item 33.

- Virtual methods should be private by default and protected if they
need access to a base classes version (except for the destructor, of
course), from http://www.gotw.ca/publications/mill18.htm.

- Header files should be self contained, from various sources.

- Destructors for base classes should be either virtual or protected.

I think I''ve probably missed (or never heard of) quite a few more.
Anyone know where I can find such things? Or have some guidelines of
their own to share?




查看这两本书:

"大规模C ++软件设计作者:John Lakos

面向对象的设计启发式作者:Arthur J. Riel


这个网站也许有帮助:

< http://www.chris-lott.org/resources/cstyle/ >



Check out these two books:
"Large-Scale C++ Software Design" by John Lakos
"Object-Oriented Design Heuristics" by Arthur J. Riel

This site may also be helpful:
<http://www.chris-lott.org/resources/cstyle/>


Pete Vidler< pv ***** @ mailblocks.com>写道:
Pete Vidler <pv*****@mailblocks.com> wrote:
我想知道是否有汇编的C ++指南在任何地方。以下是我到目前为止所收到的一些内容(例如):

- 功能应该放在一个屏幕上,来自不同的来源。

- 非 - 叶子类应该是抽象的(有纯虚方法),来自更有效的C ++,第33项。

- 虚拟方法默认应该是私有的,如果它们需要访问则受到保护从 http://www.gotw.ca/publications/mill18.htm

- 头文件应该是自包含的,来自各种来源。

- 基类的析构函数应该是虚拟的或受保护的。

我想我可能已经错过了(或者从未听说过)更多。
任何人都知道我在哪里可以找到这样的事情呢?或者有一些自己要分享的指南?
I''m wondering if there is a compilation of C++ guidelines out there
anywhere. Here are some of the ones I''ve picked up so far (as examples):

- Functions should fit on one screen, from various sources.

- Non-leaf classes should be abstract (have pure virtual methods), from
More Effective C++, Item 33.

- Virtual methods should be private by default and protected if they
need access to a base classes version (except for the destructor, of
course), from http://www.gotw.ca/publications/mill18.htm.

- Header files should be self contained, from various sources.

- Destructors for base classes should be either virtual or protected.

I think I''ve probably missed (or never heard of) quite a few more.
Anyone know where I can find such things? Or have some guidelines of
their own to share?




查看这两本书:

"大规模C ++软件设计作者:John Lakos

面向对象的设计启发式作者:Arthur J. Riel


这个网站也许有帮助:

< http://www.chris-lott.org/resources/cstyle/ >



Check out these two books:
"Large-Scale C++ Software Design" by John Lakos
"Object-Oriented Design Heuristics" by Arthur J. Riel

This site may also be helpful:
<http://www.chris-lott.org/resources/cstyle/>


Pete Vidler写道:
Pete Vidler wrote:
我想知道是否有汇编的C ++指南
任何地方。以下是我到目前为止所获得的一些内容(例如):

- 功能应该适合各种来源的屏幕。


功能应该有1到5个活动。在更高级别的语言中,这个

转换为1到5个语句,但是C ++需要很多索具和

管道。

- 非叶子类应该是抽象的(有纯虚方法),来自
更有效的C ++,第33项。


Addison Wesley的语料库[朗文]的C ++和理论书籍形成已知风格的

风雨。尝试/设计模式/,/大规模C ++软件

设计/,和/重构/。

- 默认情况下,虚拟方法应该是私有的,如果它们是
需要从 http://www.gotw.ca/publications/mill18.htm


另外尝试/ Exceptional C ++ /,来自Herb Sutter。

- 头文件应该是自包含的,来自各种来源。


这里的含义是你总是可以添加一个新的#include" thing.h"并且它可以自行处理
。你永远不需要在它上面添加另一个#include。

/ Large Scale /非常详细地介绍它。

- 基类的析构函数应该是虚拟的或受保护的。


从未听说过受保护的一个。

我想我可能已经错过了(或者从未听说过)更多。
任何人都知道在哪里可以找到这样的东西?或者有一些他们自己分享的指导方针?
I''m wondering if there is a compilation of C++ guidelines out there
anywhere. Here are some of the ones I''ve picked up so far (as examples):

- Functions should fit on one screen, from various sources.
Functions should have 1 to 5 activities. In higher level languages this
translates to 1 to 5 statements, but C++ requires a lot of rigging and
piping.
- Non-leaf classes should be abstract (have pure virtual methods), from
More Effective C++, Item 33.
The corpus of Addison Wesley [Longman]''s C++ and theory books form the
pinacle of known style. Try /Design Patterns/, /Large Scale C++ Software
Design/, and /Refactoring/.
- Virtual methods should be private by default and protected if they
need access to a base classes version (except for the destructor, of
course), from http://www.gotw.ca/publications/mill18.htm.
Also try /Exceptional C++/, by Herb Sutter.
- Header files should be self contained, from various sources.
The implication here is you can always add a new #include "thing.h", and it
takes care of itself. You never need to add another #include above it.
/Large Scale/ covers this in great detail.
- Destructors for base classes should be either virtual or protected.
Never heard of the "protected" one.
I think I''ve probably missed (or never heard of) quite a few more.
Anyone know where I can find such things? Or have some guidelines of
their own to share?




这些指导原则占据了一席之地。一方面,我们有要求,即C ++的最小表达式强制执行。除非分析显示需要删除类''''vtable'',否则你应该使所有析构函数虚拟

。在另一个

结束时,我们有团队特定的模式和行为。例如,一个团队可能

对所有集合类采用STL,而另一个团队可能有另一个

库,因此不应使用STL。但是我们应该为AW写好

书籍时推荐STL。


-

Phlip
http://www.xpsd.org/cgi-bin/wiki?Tes ... UserInterfaces


这篇关于C ++指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆