简体   繁体   English

C ++通过引用传递类对象?

[英]c++ pass class object by reference?

I am having trouble working with third party dll's, libs and header files. 我在使用第三方dll,库和头文件时遇到问题。 I am trying to call a function and have it return a value with no luck. 我试图调用一个函数,让它返回没有运气的值。 Here is the function that is suppose to be called. 这是假定要调用的函数。

bool COAuthSDK::GetRequestToken(CClientDetails &objClientDetails) 布尔COAuthSDK :: GetRequestToken(CClientDetails&objClientDetails)

It has this info of what it needs 它具有所需信息

Name IN/OUT Description m_environment IN Optional. 名称IN / OUT描述m_environment IN可选。 Possible values are SANDBOX (default) and LIVE. 可能的值为SANDBOX(默认)和LIVE。 m_strConsumerKey IN OAuth consumer key provided by E*TRADE m_strConsumerSecret IN OAuth consumer secret provided by E*TRADE m_strToken OUT Returned by the function if successful m_strTokenSecret OUT Returned by the function if successful m_strCallback IN Optional; m_strConsumerKey IN由E * TRADE提供的OAuth使用方密钥m_strConsumerSecret IN由E * TRADE提供的OAuth使用方密钥m_strToken OUT如果成功则由函数返回m_strTokenSecret OUT如果成功则由函数返回m_strCallback IN可选;可选。 default value is "oob" 默认值为“ oob”

Here is the COAuthSDK header. 这是COAuthSDK标头。

#ifndef _OAUTHSDK_H_INCLUDED_
#define _OAUTHSDK_H_INCLUDED_

#include "ETCOMMON\CommonDefs.h"
#include "ETCOMMON\OAuthHelper.h"
using namespace std;

#ifdef OAUTH_LIBRARY_EXPORT // inside DLL
#   define OAUTH_API   __declspec(dllexport)
#else //outside DLL
#   define OAUTH_API   __declspec(dllimport)
#endif  //OAUTH_LIBRARY_EXPORT

class OAUTH_API COAuthSDK
{
public:
COAuthSDK(void);
virtual ~COAuthSDK(void);

bool GetRequestToken(CClientDetails &objClientDetails) throw (...);
bool GetAccessToken(CClientDetails &objClientDetails,string strVerifier) throw (...);
void RenewToken(CClientDetails &objClientDetails) throw (...);
void RevokeToken(CClientDetails &objClientDetails) throw (...);
string AuthorizeUrl(CClientDetails &objClientDetails) throw (...);

string GetProtectedResourse(CClientDetails &objClientDetails,string strUrl,       HttpMethodConstants httpMethod = GETMethod, string postParameters = NULL) throw (...);

}; };

#endif//_OAUTHSDK_H_INCLUDED_

and the CClientDetails header 和CClientDetails标头

#pragma once

#ifndef _CLIENTDETAILS_H_INCLUDED_
#define _CLIENTDETAILS_H_INCLUDED_

using namespace std;

#include "CommonDefs.h"

#ifdef COMMON_LIBRARY_EXPORT // inside DLL
#   define COMMON_API   __declspec(dllexport)
#else // outside DLL
#   define COMMON_API   __declspec(dllimport)
#endif  // COMMON_LIBRARY_EXPORT

class COMMON_API CClientDetails
{
public:
CClientDetails();
CClientDetails(string strConsumerKey,string strConsumerSecret,Environment environment);
virtual ~CClientDetails ();

Environment GetEnv();
void SetEnv(Environment env);

string GetConsumerKey();
void SetConsumerKey(string consumerKey);

string GetConsumerSecret();
void SetConsumerSecret(string consumerSecret);

string GetToken();
void SetToken(string token);

string GetTokenSecret();
void SetTokenSecret(string tokenSecret);

private :
Environment m_environment;
string m_strConsumerKey;
string m_strConsumerSecret;
string m_strToken;
string m_strTokenSecret;
string m_strCallback;
};
#endif//_CLIENTDETAILS_H_INCLUDED

and my main CPP. 还有我的主要CPP

int _tmain(int argc, _TCHAR* argv[]){CClientDetails clientDetails;

CClientDetails objClientDetails;
GetRequestToken(CClientDetails &objClientDetails);
objClientDetails.SetEnv(SANDBOX);
objClientDetails.SetConsumerKey("1f5328f725dee654e0a4499f161b8fe4c6e");
objClientDetails.SetConsumerSecret("d39a8043cc0c7686920fd0655e47281e6a5");
objClientDetails.GetToken();
objClientDetails.GetTokenSecret();
cin.get();
cin.get();
return 0;

  }`

When I try to build the function it says that its in the dll's so I know I have to call it. 当我尝试构建函数时,它说它在dll中,因此我知道必须调用它。 If anyone could help that would be greatly appreciated. 如果有人可以帮助,将不胜感激。 Here is the link to the build site if needed https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-SDKGuides-VC 如果需要,这里是到构建站点的链接https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-SDKGuides-VC

GetRequestToken(CClientDetails &objClientDetails);

is not good. 不好 You need something like 你需要类似的东西

COAuthSDK sdk;
sdk.GetRequestToken(objClientDetails);

note that it's just some likely correct syntax, you shall figure out from dox how to obtain an sdk instance for use. 请注意,这只是一些可能正确的语法,您应从dox中弄清楚如何获取要使用的sdk实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM