T
The|Godfather
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::StatementInternals::StatementInternals(bool & status)
: nParams(0),
capacity(0),
tuple_num(0),
alter_session_statement(false),
select_statement(false)
{sprintf(stmt_internals->stmt_name,"%llx",embeddedConnection.GetConnectionInternals(__LINE__,
__FILE__)->prep_cnt++);
}
The error is in the line:
sprintf(stmt_internals->stmt_name,"%llx",embeddedConnection.GetConnectionInternals(__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
embeddedConnection.GetConnectionInternals(), 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::StatementInternals::StatementInternals(bool & status)
: nParams(0),
capacity(0),
tuple_num(0),
alter_session_statement(false),
select_statement(false)
{sprintf(stmt_internals->stmt_name,"%llx",embeddedConnection.GetConnectionInternals(__LINE__,
__FILE__)->prep_cnt++);
}
The error is in the line:
sprintf(stmt_internals->stmt_name,"%llx",embeddedConnection.GetConnectionInternals(__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
embeddedConnection.GetConnectionInternals(), 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