jjzjj

GetAccount

全部标签

c++ - 从 C++ 返回对对象的引用时,是否需要在返回变量中使用 "&"运算符?

假设我有以下代码:#includeusingnamespacestd;classAccount{private:floatbalance;public:Account(){balance=0.0;};floatGetBalance(){returnbalance;};voidSetBalance(floatnewBalance){balance=newBalance;};};AccountmainAccount;Account&GetAccount(){returnmainAccount;}voidPrintAccountInfo(){cout当我运行它时,我得到以下输出(如预期的那样

无法解析方法getAccount()

所以我一直在关注指南这里为了设置Google登录,这是所需的最后一个代码(进行少量修改):privatevoidhandleSignInResult(GoogleSignInResultresult){System.out.println("TAG-handleSignInResult:"+result.isSuccess());if(result.isSuccess()){//Signedinsuccessfully,showauthenticatedUI.GoogleSignInAccountacct=result.getSignInAccount();GoogleAccountCrede