Passing template class by reference
Minhaj Ahmed
MinhajA@bsquare.com
Wed Feb 3 23:07:00 GMT 2010
How do you pass a template class object by reference? As an example:
Say we have a namespace util and
Namespace NewName
{
Class A
{
SomeRoutine(util::CSomeUtilClass<CDataWrapperClass>
&msg);
};
}
Now when I call this method in a cpp file gcc complains that
"error: with
NewName::A::SomeRoutine(util::CSomeUtilClass<CDataWrapperClass>&)'
And
Error: no matching function for call to
'NewName::A::SomeRoutine(util::CSomeUtilClass<CDataWrapperClass>&)'
Any idea how I can get around this? I can remove the '&' from method
and have it compile just fine! Any help would be greatly appreciated...
Also I've another strange problem with nested classes:
So let say we have
Class SemaphoreC
{
...
};
Class data
{
...
};
Namespace util
{
tempate <class T>
Class SmartPtr
{
...
};
template <class T>
class someTemplate
{
Public:
GetSem(){return m_sem);
Private:
SemaphoreC m_sem;
};
}
class A
{
Class Nested
{
Class A *a_ptr;
};
Private:
TrytogetSem();
util::someTemplate< util::SmartPtr<data> > var;
};
Now when the GetSem is called from A::TrytogetSem() ie.
A::TrytogetSem()
{
Declared in class Nested declared in class A
member of someTemplate
| |
|
| |
|
SemaphoreC s = a_ptr-> var.
GetSem();
}
And gcc complains that it's unable to convert void * to LONG? I can
declare 's' as void * and the error disappears
Regards,
More information about the Libstdc++
mailing list