What does C ++ syntax mean?

Here is the statement. I believe that this is using the translation operator, but what is a deal with a message increment?

(*C)(x_i,gi_tn,f)++;

Declaration and Definition C:

std::auto_ptr<conditional_density> C(new conditional_density());

Class declaration conditional_density:

class conditional_density: public datmoConditionalDensity{
public:
  static const double l_min, l_max, delta;
  static double x_scale[X_COUNT];    // input log luminance scale
  double *g_scale;    // contrast scale
  double *f_scale;    // frequency scale      
  const double g_max;    
  double total;    
  int x_count, g_count, f_count; // Number of elements    
  double *C;          // Conditional probability function    
  conditional_density( const float pix_per_deg = 30.f ) :
    g_max( 0.7f ){
    //Irrelevant to the question               
  }    

  double& operator()( int x, int g, int f )
  {
    assert( (x + g*x_count + f*x_count*g_count >= 0) && (x + g*x_count + f*x_count*g_count < x_count*g_count*f_count) );
    return C[x + g*x_count + f*x_count*g_count];
  }

};

The parent class datmoConditionalDensityhas only a virtual destructor.

It would be easy to answer this by debugging the code, but this code would not be created under Windows (a bunch of external libraries are required).

+5
source share
3 answers
(*C)(x_i,gi_tn,f)++;

Let me break it:

(*C)

This plays out the pointer. C is a smart pointer and therefore can be dereferenced to get a reference to the actual element. The result is an object conditional_density.

(*C)(x_i,gi_tn,f)

() conditional_density. , , . , :

  double& operator()( int x, int g, int f )
  {
    assert( (x + g*x_count + f*x_count*g_count >= 0) && (x + g*x_count + f*x_count*g_count < x_count*g_count*f_count) );
    return C[x + g*x_count + f*x_count*g_count];
  }

double. :

(*C)(x_i,gi_tn,f)++

() double, ++ , .

+11

, C (, operator()). ,

(*C)(x_i,gi_tn,f)

" C, , x_i, gi_tn f. , double&,

(*C)(x_i,gi_tn,f)++;

" C, , , ".

, !

+3

The operator () (int, int, int) returns a reference to an element of the static double array.

The ++ operator increments the value that was returned.

0
source

All Articles