1
// t1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
struct Origin
{
Origin(int _x=0, int _y=0) : x(_x), y(_y) {}
int x;
int y;
};
struct Extents
{
Extents(int _width=0, int _height=0) : width(_width), height(_height) {}
int width;
int height;
};
class Rectangle
{
public:
Rectangle(const Origin& o, const Extents& e) : m_origin(o), m_extents(e) {}
Origin m_origin;
Extents m_extents;
};
int _tmain(int argc, _TCHAR* argv[])
{
Rectangle w(Origin(), Extents()); // declare a function 'w'
Origin o(1, 2);
Extents e(3, 4);
Rectangle w2(o, e); // define a variable 'w2'
return 0;
}
問題>正如我們所看到的,w
是函數的聲明。 w2
是變量的定義。 從編譯器或語言的角度來看,使它們不同的關鍵區別是什麼?矩形w(Origin(),Extents())和Rectangle w2(o,e)之間的區別
只需搜索「最令人頭疼的解析」。 – kennytm 2012-02-09 18:57:52