• 7845阅读
  • 2回复

qwt例子 [复制链接]

上一主题 下一主题
离线jiang_198586
 

只看楼主 倒序阅读 楼主  发表于: 2010-08-27
— 本帖被 XChinux 执行加亮操作(2010-09-03) —
在qwt安装包内的examples下的simple_plot例子下的cSin->setData(SimpleData(::sin, nPoints));是什么意思?看不懂?

class SimpleData: public QwtData
{
    // The x values depend on its index and the y values
    // can be calculated from the corresponding x value.
    // So we don磘 need to store the values.
    // Such an implementation is slower because every point
    // has to be recalculated for every replot, but it demonstrates how
    // QwtData can be used.

public:
    SimpleData(double(*y)(double), size_t size):
        d_size(size),
        d_y(y)
    {
    }

    virtual QwtData *copy() const
    {
        return new SimpleData(d_y, d_size);
    }

    virtual size_t size() const
    {
        return d_size;
    }

    virtual double x(size_t i) const
    {
        return 0.1 * i;
    }

    virtual double y(size_t i) const
    {
        return d_y(x(i));
    }
private:
    size_t d_size;
    double(*d_y)(double);
};
离线dbzhang800

只看该作者 1楼 发表于: 2010-08-27
找本C语言的书,看 "函数指针" 部分
离线dbzhang800

只看该作者 2楼 发表于: 2010-08-27
如果你是对那两个冒号有疑问,找本C++的书,看 namespace 部分。然后看C的 "函数指针"
快速回复
限100 字节
 
上一个 下一个