c++ pass class object by reference
Jun 25, 2013 at 5:14pm UTC
I am having trouble working with third party dll's, libs and header files. I am trying to call a function and have it return a value with know luck.
here is the function that is suppose to be called.
bool COAuthSDK::GetRequestToken(CClientDetails &objClientDetails)
it has this info of what it needs
1 2 3 4 5 6 7
Name IN/OUT Description
m_environment IN Optional. Possible values are SANDBOX (default ) and 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; default value is "oob"
here is the COAuthSDK header
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#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_
here is my main cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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. 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
Last edited on Jun 25, 2013 at 9:41pm UTC
Jun 25, 2013 at 11:03pm UTC
Line 4 of main.cpp doesn't make sense.
It appears you're declaring GetRequestToken as a global function prototype.
According to the COAuthSDK header, GetRequestToken is in the COAuthSDK namespace. The linker is not going to be able to resolve your call.
Topic archived. No new replies allowed.