im getting an error "'const std::string &RGNWallet::getAddress(void)': cannot convert…
- User
im getting an error "'const std::string &RGNWallet::getAddress(void)': cannot convert 'this' pointer from 'const RGNWallet' to 'RGNWallet &'"
void UBP_RGNGetUserWalletsResponse::Raise(RGNGetUserWalletsResponse response) { FBP_RGNGetUserWalletsResponseData ResponseData; for (const RGNWallet& wallet : response.getWallets()) { FBP_RGNWallet Wallet; Wallet.Address = FString(wallet.getAddress().c_str()); ResponseData.Wallets.Add(Wallet); } ResponseEvent.ExecuteIfBound(ResponseData); }
- Assistant
The error message indicates that you are trying to call a non-const member function (getAddress()) on a const object (const RGNWallet).
To fix this error, you can modify the getWallets() function in the RGNGetUserWalletsResponse class to return a const reference of the RGNWallet objects:
cppconst std::vector<RGNWallet>& RGNGetUserWalletsResponse::getWallets() const { return wallets; }By adding the const keyword after the function declaration, you are specifying that this function does not modify any non-mutable data members of the class. Therefore, you can call this function on a const object.
Note that you need to make sure the getWallets() function is implemented correctly in the RGNGetUserWalletsResponse class.