2010-09-18

多くのプログラマは言語を表面的な理解だけで使っている


使

aggregateC++
int a[100] = {0} ;

aC++{0}{}
int a[100] = {} ;

C++{0}C++{0}


T x = {0} ;

T0staticstaticzero-initialized
int a[3] = {100} ;

a[0]100a[1]a[2]

static
int a[1000] = {} ; // すべての要素をstaticストレージと同じ方法で初期化(すなわち、ゼロ初期化)

C++{0}C
int a[5] = { } ; // C言語ではエラー、C++ではOK

C++CCC++C99{}C99C++CC

{0}{0}



dynamic_castpolymorphicdynamic_cast
struct Base { } ;
struct Derived : Base { } ;

int main()
{
    Derived d ;
    Base & b = dynamic_cast< Base & >(d) ;
}

static_cast使dynamic_castdynamic_cast使

const_castCV-qualifierCV-qualifier
int main()
{
    int const * ptr = nullptr ;
    const_cast< int const *>( ptr ) ;
}

const_castCV-qualifierCV-qualifier





CC++CstaticC++value-initialize


11 comments:

Anonymous said...

> 

 typo 


September 18, 2010 at 2:27PM
said...


Google


September 18, 2010 at 3:06PM
Anonymous said...


沿

C++()


September 19, 2010 at 2:32AM
Anonymous said...


C
C++90C使


September 19, 2010 at 3:12AM
Anonymous said...







September 19, 2010 at 9:02AM
Anonymous said...


CC



2030C



November 8, 2010 at 11:13PM
Egtra said...


int a[10] = {0};int a[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

int a[10]; memchr(a, '\0', sizeof a);


October 1, 2011 at 2:03AM
said...


CC++000使0


October 1, 2011 at 5:13AM
Anonymous said...





July 14, 2016 at 10:46PM
Anonymous said...




>C

C使CC++


August 30, 2019 at 10:53AM
Unknown said...


CppC