我现在正在与下面的提案作斗争,我想知道合法的,在较小程度上反对它的道德论点.
我们有什么:
#include <vector>
class T;
class C
{
public:
C() { }
~C( ) { /*something non-trivial: say, calls delete for all elements in v*/ }
// a lot of member functions that modify C
// a lot of member functions that don't modify C
private:
C(C const &);
C& operator=(C const&);
private:
std::vector< T* > v;
};
void init(C& c) { } // cannot be moved inside C
// ...
int main()
{
// bad: two-phase initialization exposed …Run Code Online (Sandbox Code Playgroud) 有时,某些函数会交换一些非常特殊的数据元组.
>>> def foo():
... return (1,2,4)
...
>>> def f(a, b, v):
... x, y, z = v
... # ...
... # suppose there are 2-4 lines of some trivial code
... # ...
... print a, b, '(', x, y, z, ')'
...
>>> f(1, 2, foo())
1 2 ( 1 2 4 )
Run Code Online (Sandbox Code Playgroud)
这里的用例是它确实是临时数据集,因此我们不想引入新类.(我们还假设元组本身只是一堆数据,因此通过索引访问元组的元素,就像print a, b, '(', v[0], v[1], v[2], ')'读者真的会感到困惑一样.)
所以无论如何.我们决定传递元组,我们想要解压缩(解构)它们.有什么好处,你可以在函数的参数列表中解压缩参数元组,所以f可以简化一下:
>>> def f(a, b, (x,y,z)):
... # ...
... # …Run Code Online (Sandbox Code Playgroud) 我已经阅读了整个教程部分sfml-dev.org并且有一些问题.
什么是视图以及如何使用它们?
我应该在视图中还是在渲染窗口中渲染内容?