码迷,mamicode.com
首页 > 其他好文 > 详细

退化Decay

时间:2015-04-24 01:03:07      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

测试代码:

#include <iostream>
#include <typeinfo>

template <typename T>
void ref (T const& x)
{
    std::cout <<"x in ref(T const&): " << typeid(x).name() << std::endl;
}

template <typename T>
void nonref(T x)
{
    std::cout << "x in nonref(T): " << typeid(x).name() << std::endl;
}

void func(char a[20], size_t b)
{
    std::cout << b << " " << sizeof(a) << std::endl;
}

int main()
{
    ref("hello");
    nonref("hello");

    char c[20] = "Hello World!";
    func(c, sizeof(c));
    return 0;
}

 

结果:

技术分享

退化Decay

标签:

原文地址:http://www.cnblogs.com/AmitX-moten/p/4452229.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!