template< class Type >
class cStack
{
Type *m_array;
int m_Top;
int m_Size;
public:cStack();
cStack(const Type&);
cStack(const cStack<Type> &);
bool Is_Full();
bool Is_Empty();
void InsertValue(const Type&);
void RemeoveValue();
~cStack();
};
template< class Type >
class Smartpointer
{
cStack<Type> *sPtr;
public: Smartpointer();
Smartpointer(const Type&);
Type* operator->();
Type& operator*();
};
int main()
{ Smartpointer<int> sptr(1);
sptr->InsertValue(2);//its not calling insertvalue
}
}
views:
25answers:
2
+1
A:
An int does not have a method called InsertValue. May-be you wanted to use a SmartPointer<cStack<int> >?
UncleBens
2010-04-27 07:49:14
I was looking at wondering if it would even compile..
Brendan Long
2010-04-27 07:50:29
A:
Your operator->() returns a Type*, not a cStack. If you want to be calling InsertValue, a pointer to Type is not what you want.
Joel
2010-04-27 07:51:09