5

While reading some boost library source code I encountered this part

template< class Value = double >
struct rk4_coefficients_a3 : boost::array< Value , 3 >
{
    rk4_coefficients_a3( void )
        {
    (*this)[0] = static_cast<Value>(0);
    (*this)[1] = static_cast<Value>(0);
    (*this)[2] = static_cast<Value>(1);
        }
};

What does the colon (:) mean after struct name?

Bociek
  • 1,195
  • 2
  • 13
  • 28

1 Answers1

4

A struct is just the same thing as a class, just with default visibility of public for its members and ancestors. So a struct can inherit from another class/struct. In your example, rk4_coefficients_a3 inherits from boost::array< Value , 3 > using public inheritance.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Zereges
  • 5,139
  • 1
  • 25
  • 49