Next: Virtual Methods, Previous: Protections, Up: Cplusplus

### 8.10 Method Modifiers (`const`, `volatile`, `const volatile`)

<< based on a6.C >>

In the class example described above all the methods have the normal modifier. This method modifier information is located just after the protection information for the method. This field has four possible character values. Normal methods use ``A`', const methods use ``B`', volatile methods use ``C`', and const volatile methods use ``D`'. Consider the class definition below:

         class A {
         public:
                 int ConstMeth (int arg) const { return arg; };
                 char VolatileMeth (char arg) volatile { return arg; };
                 float ConstVolMeth (float arg) const volatile {return arg; };
         };

This class is described by the following stab:

         .stabs "class(A):sym_desc(struct)type_def(20)=type_desc(struct)struct_bytes(1)
                 meth_name(ConstMeth)::type_def(21)sym_desc(method)
                 returning(int);:arg(int);protection(public)modifier(const)virtual(no);
                 meth_name(VolatileMeth)::type_def(22)=sym_desc(method)
                 returning(char);:arg(char);protection(public)modifier(volatile)virt(no)
                 meth_name(ConstVolMeth)::type_def(23)=sym_desc(method)
                 returning(float);:arg(float);protection(public)modifier(const volatile)
                 virtual(no);;", ...

         .stabs "A:T20=s1ConstMeth::21=##1;:i;2B.;VolatileMeth::22=##2;:c;2C.;
                      ConstVolMeth::23=##12;:f;2D.;;",128,0,0,0