Hi everybody,
I read Scotte Meyer's "Effective C++" book twice and I know that
he mentioned something specific about constructors and destructors that
was related to the
following error/warning: "error: invalid use of nonstatic data member "
However, he did NOT mention this error in the book explicitly.It
happens always in the constructor when you try to initialize some data
members in the constructor and try to accsess other data members. Of
course,one can always move the initialization away from the
constructor , but that is not the goal:
UP_SQLPrepQuery ::StatementInte rnals::Statemen tInternals(bool & status)
: nParams(0),
capacity(0),
tuple_num(0),
alter_session_s tatement(false) ,
select_statemen t(false)
{sprintf(stmt_i nternals->stmt_name,"%ll x",embeddedConn ection.GetConne ctionInternals( __LINE__,
__FILE__)->prep_cnt++);
}
The error is in the line:
sprintf(stmt_in ternals->stmt_name,"%ll x",embeddedConn ection.GetConne ctionInternals( __LINE__,
__FILE__)->prep_cnt++);
}
Here , I try to get some value through a function. Scott said something
about NOT doing that in constructors, but I am not sure and I could
NOT find anything. The problem is with the Function
embeddedConnect ion.GetConnecti onInternals(), which should return a
pointer to an object.
I am using gcc (GCC) 3.4.2 under: x86_64 GNU/Linux
Please, advise.
Cheers,
Dragomir Stanchev
I read Scotte Meyer's "Effective C++" book twice and I know that
he mentioned something specific about constructors and destructors that
was related to the
following error/warning: "error: invalid use of nonstatic data member "
However, he did NOT mention this error in the book explicitly.It
happens always in the constructor when you try to initialize some data
members in the constructor and try to accsess other data members. Of
course,one can always move the initialization away from the
constructor , but that is not the goal:
UP_SQLPrepQuery ::StatementInte rnals::Statemen tInternals(bool & status)
: nParams(0),
capacity(0),
tuple_num(0),
alter_session_s tatement(false) ,
select_statemen t(false)
{sprintf(stmt_i nternals->stmt_name,"%ll x",embeddedConn ection.GetConne ctionInternals( __LINE__,
__FILE__)->prep_cnt++);
}
The error is in the line:
sprintf(stmt_in ternals->stmt_name,"%ll x",embeddedConn ection.GetConne ctionInternals( __LINE__,
__FILE__)->prep_cnt++);
}
Here , I try to get some value through a function. Scott said something
about NOT doing that in constructors, but I am not sure and I could
NOT find anything. The problem is with the Function
embeddedConnect ion.GetConnecti onInternals(), which should return a
pointer to an object.
I am using gcc (GCC) 3.4.2 under: x86_64 GNU/Linux
Please, advise.
Cheers,
Dragomir Stanchev
Comment