如何在同一个类的公共函数中调用私有类函数(带参数)?

时间:2016-05-31 01:07:36

标签: c++ visual-c++ syntax

所以,我正在编写一个专注于运算符重载的程序。

我试图写一个私有函数来找到两个有理数的最小公分母(main中的对象)。现在,访问者只是不喜欢私有lcd函数的参数。

这是我的lcd私人功能:

long CRational::lcd(const CRational &rationalNumber) const{
    long gCF = 0;
    long lCD = 0;
    if (m_denominator != 0 && rationalNumber.m_denominator != 0){
        gCF = gcf(m_denominator, rationalNumber.m_denominator);
        lCD = ((m_denominator / gCF)*rationalNumber.m_denominator);
    }

    return lCD;
}

这是我为访问者尝试的内容:

long CRational::getLCD() const
{

    return lcd(const CRational &rationalNumber);
}

现在,我在const和& rationalNumber下得到红色波浪形。 不允许使用const - name类型 & rationalNumber - unidentified

希望有人能在我疯了之前帮助我吗?

1 个答案:

答案 0 :(得分:1)

试试这个:

  <?xml version="1.0" encoding="utf-8"?> 
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
      <t:RequestServerVersion Version="Exchange2013_SP1" /> 
    </soap:Header> 
    <soap:Body> 
      <m:FindItem Traversal="Shallow"> 
        <m:ItemShape> 
          <t:BaseShape>AllProperties</t:BaseShape> 
        </m:ItemShape> 
        <m:IndexedPageItemView MaxEntriesReturned="10" Offset="0" BasePoint="Beginning" /> 
        <m:Restriction> 
          <t:Contains ContainmentMode="FullString" ContainmentComparison="IgnoreCase"> 
            <t:FieldURI FieldURI="item:Categories" /> 
            <t:Constant Value="MyCategory" /> 
          </t:Contains> 
        </m:Restriction> 
        <m:ParentFolderIds> 
          <t:DistinguishedFolderId Id="inbox" /> 
          <t:DistinguishedFolderId Id="sentitems" /> 
        </m:ParentFolderIds> 
      </m:FindItem> 
    </soap:Body> 
  </soap:Envelope>