B
Boni
Dear all,
can I prohibit that my class will be passed by value (i.e created a copy on
stack when function is called)? I want to prohibit passing my class by
value. I thougth that declare a default constructor to private would do the
job, but no.
When myfunc is called some construcor goes called, but not the explicit
one.I have noidea which one is it. I am running out of ideas.
With best wishes,
Boni
Any ideas?
template< typename T> void myfunc(const templclass<T> a){
...
}
template< typename T> struct templclass
{
explicit templclass(std::string Name_, T DefaultVal_=0)
{
cout<<"bhcadshhvfah"<<endl;
};
std:stream& operator<< (std:stream& os)const {
return os<<m_Value;
};
//assignment operator
templclass& operator = ( const T a ){
m_Value=a;
return *this;
}
operator T ( ){
return m_Value;
}
private:
templclass();
T m_Value;
templclass( T);
};
can I prohibit that my class will be passed by value (i.e created a copy on
stack when function is called)? I want to prohibit passing my class by
value. I thougth that declare a default constructor to private would do the
job, but no.
When myfunc is called some construcor goes called, but not the explicit
one.I have noidea which one is it. I am running out of ideas.
With best wishes,
Boni
Any ideas?
template< typename T> void myfunc(const templclass<T> a){
...
}
template< typename T> struct templclass
{
explicit templclass(std::string Name_, T DefaultVal_=0)
{
cout<<"bhcadshhvfah"<<endl;
};
std:stream& operator<< (std:stream& os)const {
return os<<m_Value;
};
//assignment operator
templclass& operator = ( const T a ){
m_Value=a;
return *this;
}
operator T ( ){
return m_Value;
}
private:
templclass();
T m_Value;
templclass( T);
};