473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

SmartPtr Issues

Hi,

I am trying to rewrite an existing class used to manage personal
data(Outlook) with Smart Pointers (RefPtr a reference counting ptr):

namespace System{
namespace WindowsMobile{
namespace PocketOutlook{

....

In .h

#include "RefPtr.h"

class OutlookSession : public Object
{
public:
friend class Folder;
friend class ContactCollection;
friend class TaskCollection;

OutlookSession();
virtual ~OutlookSession();

bool get_IsLoggedIn() {return m_bLoggedIn; }
System::RefPtr<ContactFolder> get_Contacts();
protected:

bool m_bLoggedIn;
IPOutlookAppPtr m_pPOOMApp;
RefPtr<ContactFolder m_rpContactFolder;
};

} // PocketOutlook
} // WindowsMobile
} // System
In .cpp
namespace System{
namespace WindowsMobile{
namespace PocketOutlook{
RefPtr<ContactFolderOutlookSession::get_Contacts()
{
if ( (m_bLoggedIn == false) )
return NULL;

if (m_rpContactFolder.isNull() == true)
m_rpContactFolder = new ContactFolder();

return m_rpContactFolder;
}
}
}
}
But when I compile I get the following error :
>System.WindowsMobile.PocketOutlook.obj : error LNK2019: unresolved
external symbol "public: __cdecl System::RefPtr<class
System::WindowsMobile::PocketOutlook::ContactFolde r>::RefPtr<class
System::WindowsMobile::PocketOutlook::ContactFolde r>(void)"
(??0?$RefPtr@VContactFolder@PocketOutlook@WindowsM obile@System@@@System@@QAA@XZ)
referenced in function "public: __cdecl
System::WindowsMobile::PocketOutlook::OutlookSessi on::OutlookSession(void)"
(??0OutlookSession@PocketOutlook@WindowsMobile@Sys tem@@QAA@XZ)

1>System.WindowsMobile.PocketOutlook.obj : error LNK2019: unresolved
external symbol "public: __cdecl System::RefPtr<class
System::WindowsMobile::PocketOutlook::ContactFolde r>::RefPtr<class
System::WindowsMobile::PocketOutlook::ContactFolde r>(class
System::WindowsMobile::PocketOutlook::ContactFolde r *)"
(??0?$RefPtr@VContactFolder@PocketOutlook@WindowsM obile@System@@@System@@QAA@PAVContactFolder@Pocket Outlook@WindowsMobile@1@@Z)
referenced in function "public: class System::RefPtr<class
System::WindowsMobile::PocketOutlook::ContactFolde r__cdecl
System::WindowsMobile::PocketOutlook::OutlookSessi on::get_Contacts(void)"
(?get_Contacts@OutlookSession@PocketOutlook@Window sMobile@System@@QAA?AV?$RefPtr@VContactFolder@Pock etOutlook@WindowsMobile@System@@@4@XZ)
1>Windows Mobile 6 Standard SDK (ARMV4I)\Debug\TestPoom.exe : fatal
error LNK1120: 2 unresolved externals

I don't understand ths missing reference since I am including RefPtr.h
(see below) :
File RefPtr.h
-----------------

#ifndef RefPtr_h
#define RefPtr_h

namespace System{

template<typename T>
class RefPtr
{
public:
~RefPtr();
RefPtr();
RefPtr(const RefPtr<T>& rhs);
RefPtr(T* ptr);

RefPtr<T>& operator=(const RefPtr<T>& rhs);
RefPtr<T>& operator=(T* ptr);

bool operator<(const RefPtr<T>& rhs) const;
bool operator==(const RefPtr<T>& rhs) const;
bool operator==(const T* rhs) const;
bool operator!=(const RefPtr<T>& rhs) const;
bool operator!=(const T* rhs) const;

bool isNull() const;

operator bool() const;
T* operator->() const;
T& operator*() const;
T* get() const;

void Release();

private:
T* m_ptr;
};

} // namespace System

#include "RefPtr.inl"

#endif

File RefPtr.inl
-----------------
namespace System{

template<typename T>
inline
RefPtr<T>::RefPtr(const RefPtr& rhs) : m_ptr(rhs.m_ptr)
{
if(m_ptr)
m_ptr->AddRef();
}

template<typename T>
inline
RefPtr<T>& RefPtr<T>::operator=(const RefPtr<T>& rhs)
{
T* const pNew = rhs.get();
if(m_ptr != pNew)
{
T* const pOld = m_ptr;
if(pNew)
pNew->AddRef();
m_ptr = pNew;
if(pOld)
pOld->Release();
}
return *this;
}

template<typename T>
inline
RefPtr<T>& RefPtr<T>::operator=(T* ptr)
{
if(m_ptr != ptr)
{
if(ptr)
ptr->AddRef();
T* const pOld = m_ptr;
m_ptr = ptr;
if(pOld)
pOld->Release();
}
return *this;
}

template<typename T>
inline
bool RefPtr<T>::operator<(const RefPtr& rhs) const
{
return (m_ptr < rhs.m_ptr);
}

template<typename T>
inline
bool RefPtr<T>::operator==(const RefPtr& rhs) const
{
return (m_ptr == rhs.m_ptr);
}

template<typename T>
inline
bool RefPtr<T>::operator==(const T* rhs) const
{
return (m_ptr == rhs);
}

template<typename T>
inline
bool RefPtr<T>::operator!=(const RefPtr& rhs) const
{
return !(*this == rhs);
}

template<typename T>
inline
bool RefPtr<T>::operator!=(const T* rhs) const
{
return (m_ptr != rhs);
}

template<typename T>
inline
RefPtr<T>::operator bool() const
{
return (m_ptr!=0);
}

template<typename T>
inline
bool RefPtr<T>::isNull() const
{
return (m_ptr == 0);
}

template<typename T>
inline
T* RefPtr<T>::get() const
{
return m_ptr;
}

template<typename T>
inline
T* RefPtr<T>::operator->() const
{
ASSERT(m_ptr!=0);
return m_ptr;
}

template<typename T>
inline
T& RefPtr<T>::operator*() const
{
ASSERT(m_ptr!=0);
return *m_ptr;
}

template<typename T>
inline
RefPtr<T>::~RefPtr()
{
Release();
}

template<typename T>
inline
void RefPtr<T>::Release()
{
if(m_ptr)
{
m_ptr->Release();
m_ptr = 0;
}
}

} //namespace System


Aug 12 '08 #1
0 1091

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Loredo | last post by:
Hi folks- I'm about to move from a Solaris 8/SPARC environment to a Dell running RedHat 9. Are there any issues I need to be aware of in bringing my Python code over (mostly scientific...
28
by: grahamd | last post by:
Who are the appropriate people to report security problems to in respect of a module included with the Python distribution? I don't feel it appropriate to be reporting it on general mailing lists.
5
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to...
2
by: malcolm | last post by:
Hello, We have a robust (.NET 1.1 c# winforms) client-server application that utilizes many typed DataSets, typed DataTables and typed DataRows. Our application is a series of windows and popup...
1
by: Aliandro | last post by:
Hi Does any one know where I can find information regarding any issues with SQL and IIS being run under windows XP SP2? as I am in the process of programmning in Dot net and neet some way of...
7
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving"...
1
by: tsar.omen | last post by:
Hello everyone, during my coding practice I have encounted the following problem: Vital code pieces: --- template <class T> class SmartPtr {
1
by: GaryDean | last post by:
We have been developing all of our .net applications on 32 bit windows using 32 bit SQL Server. We are being asked to now deploy to servers running 64bit windows and 64bit SQL Server. Are there...
3
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.