C++ *这->;不能用作函数

C++ *这->;不能用作函数,c++,operator-overloading,this,C++,Operator Overloading,This,下面是我在头文件中创建的一个类的摘录: typedef double real; class Grid{ public : explicit Grid (); explicit Grid(size_t level ); Grid(const Grid & grid ); ~ Grid (); const Grid & operator =( const Grid & grid );

下面是我在头文件中创建的一个类的摘录:

typedef double real;

class Grid{
   public :

      explicit Grid ();
      explicit Grid(size_t level );
      Grid(const Grid & grid );

      ~ Grid ();


      const Grid & operator =( const Grid & grid );

      inline real & operator ()( size_t i , size_t j );
      inline real operator ()( size_t i ,size_t j ) const;

      void fill( real value );
      void setBoundary ( real value );

 private :

   size_t y_ ; // number of rows 
   size_t x_ ; // number of columns 
   real h_ ; // mesh size 
   real * v_ ; //  values 
};
下面是我在一个单独的.cpp文件中为先前声明的函数编写的代码的摘录。请注意,我只包含了与我的错误相关的部分

  inline real&  Grid :: operator ()( size_t i , size_t j ){
    if( (i >= y_) || (j>=x_ ) )
      throw std::invalid_argument( "Index out of bounds" );
    return v_ [i* x_ +j];
  }

  inline real Grid::operator ()( size_t i ,size_t j ) const{
    if( (i >= y_) || (j>=x_ ) )
      throw std::invalid_argument( "Index out of bounds" );
    return v_[i* x_+j];
  }


  void Grid::fill( real value ){
   for(size_t i=1;i<y_;++i){
    for(size_t j=1;j<x_;++j)
     v_(i,j)=value;
   }

  }

 void Grid::setBoundary ( real value ){
    size_t i = 0;
    for(size_t j=0;j<x_;++j){
     v_(i,j)=value;
    }
    i = y_;
    for(size_t j=0;j<x_;++j){
     v_(i,j)=value;
    }
    size_t j = 0;
    for(size_t i=0;i<y_;++i){
     v_(i,j)=value;
    }
    j = x_;
    for(size_t i=0;i<y_;++i){
     v_(i,j)=value;
    }
  }
inline real&Grid::operator()(大小为i,大小为j){
如果((i>=y| |(j>=x|))
抛出std::无效的_参数(“索引超出范围”);
返回v_[i*x_+j];
}
内联实网格::运算符()(大小为i,大小为j)常量{
如果((i>=y| |(j>=x|))
抛出std::无效的_参数(“索引超出范围”);
返回v_[i*x_+j];
}
空心网格::填充(实际值){

for(size\u t i=1;i
v\u
是一个
real*
,即指针。指针没有
运算符()
,因此您无法编写
v(某物)

您已经为
网格
类提供了
操作符()
的重载。如果要使用该重载,您需要在
研磨
类的对象上使用
()
v_
不是
网格
类的对象


您可能希望对当前对象(即正在调用
填充
设置边界的对象)调用
操作符()
。为此,您需要编写
(*此)(参数)

v_
是一个
实数*
,即一个指针。指针没有
操作符()
,所以你不能写
v_uu(某物)

您已经为
网格
类提供了
操作符()
的重载。如果要使用该重载,您需要在
研磨
类的对象上使用
()
v_
不是
网格
类的对象

您可能希望对当前对象(即正在调用
填充
设置边界的对象)调用
操作符()
。为此,您需要编写
(*此)(参数)

,当您编写
v_u(i,j)
时,您没有调用重载的
()
操作符。您应该尝试
(*此)(i,j)

当您编写
v(i,j)
时,您没有调用重载的
()
操作符。您应该尝试
(*此)(i,j)