#include <iostream>
#include <string>
using namespace std;

struct Print {
    template<typename T>
    Print(T t){
        cout<<(t+=10);
    }
};

struct S {
    S(int a){
        cout << a << endl;
    };
};

void foo(double a) {
  S w(int(a));                  // function declaration
//   S x(int());                   // function declaration
  S y((int(a)));                // object declaration
  S yy((int)a);                  // object declaration
  S z = int(a);                 // object declaration 
}

template <class T> struct X {};
template <int N> struct Y {};
X<int()> a;                     // type-id 
X<int(1)> b;                    // expression (ill-formed) 
Y<int()> c;                     // type-id (ill-formed) 
Y<int(1)> d;                    // expression 
void foo(signed char a) {
  sizeof(int());                // type-id (ill-formed)
  sizeof(int(a));               // expression
  sizeof(int(unsigned(a)));     // type-id (ill-formed) 
  (int())+1;                    // type-id (ill-formed)
  (int(a))+1;                   // expression
  (int(unsigned(a)))+1;         // type-id (ill-formed) 
 }

int main()
{
    // 这句为什么是一句函数声明而不是变量创建?
    double a = 3.9;
    // Print p(int(a));         // function declaration
    
    // cout << sizeof(int(1)) << endl;
    foo(a);
    
    return 0;
}

参考:

  1. 为什么以下代码是一句函数声明而不是变量创建?