zoukankan      html  css  js  c++  java
  • 关于c++中public & private方法调用问题

    class IDNoIdentifier
    {
    public:
        IDNoIdentifier();
        ~IDNoIdentifier();
    
        typedef vector<cv::Rect> CvRectVectorType;
    
        bool Init();
        bool Cleanup();
        bool HandleData(const Mat& rawImg,string& sNoInfo,string& sError);
    
    private:
        bool IDNoLocation(const Mat& rawImg,        //输入原始BGR24数据
            Mat& dstImg,                            //经偏转校正等处理后的结果图,BGR8(灰度图),该函数内创建内存
            CvRectVectorType& IDNoVector,            //基于灰度图的字符位置序列
            string& sError);                        //如果处理失败,返回失败原因
    
        bool IDNoIdentify(const Mat& dstImg,const CvRectVectorType& IDNoVector,string& sInfo,string& sError);
    
    private:
    };
    bool IDNoIdentifier::HandleData( const Mat& rawImg,string& sNoInfo,string& sError)
    {
        if (rawImg.empty())
        {
            return false;
        }
        Mat dstImg;
        CvRectVectorType posionVec; 
        if (!IDNoLocation(rawImg,dstImg,posionVec,sError))
        {
            if (!dstImg.empty())
            {
                dstImg.release();
            }
            return false;
        }
    
    ....
    }

    public类型的HandleData里面包括了一个private的IDNoLocation

    class codeExtract
    {
    public:
        codeExtract();
        ~codeExtract();
    private:
        
        Mat picProcess(Mat img);
    }
    bool IDNoIdentifier::IDNoLocation( const Mat& rawImg,Mat& dstImg,CvRectVectorType& IDNoVector,string& sError)
    {
        
        codeExtract code;
        
        /*图片二值化*/
        Mat img=code.picProcess(rawImg);   //字符清楚,矫正角度
    ...
    }

    会报错, error C2248: “codeExtract::picProcess”: 无法访问 private 成员(在“codeExtract”类中声明)

    原因:因为这是IDNoIdentifier类下的方法啊。在这个类下不能看到类codeExtract中定义的私有方法滴

  • 相关阅读:
    SQL_server 将表中的记录 转换成 Insert(插入) SQL 语句
    Delphi DBGridEh导出Excel
    hdu 2018 母牛的故事
    hdu 2084 数塔
    hdu 2190 重建希望小学
    hdu 2501 Tiling_easy version
    hdu 2046 骨牌铺方格
    hdu 2045 不容易系列之(3)—— LELE的RPG难题
    高精度模板
    各种平面分割问题总结(转)
  • 原文地址:https://www.cnblogs.com/Daringoo/p/4495341.html
Copyright © 2011-2022 走看看