"marcus" <ma************@koping.net> wrote in message
news:1a*************************@posting.google.co m...
I have this class A that contains a method A_method that opens a file
and does fgets.
I also have a template class B that contains a method B_method that
takes a class A object as template type. B_method then uses this A
object to call A_method.
here is a snippet (pseudo)
In class A.cpp:
===============
B <A> myVar;
// method that uses method of template class
A::someMethod(){
myVar.B_method(this);
.
.
}
// method to be called from template class
A::A_method(char *fileName){
char iLine[200];
int meshCount = 0;
FILE *stream = fopen(fileName, "r");
//geometryData = NULL;
if(stream != NULL){
// loop through parsing every line in the file
while (fgets(iLine, 200, stream) != NULL){
.
.
}
}
}
In class B.h:
=============
B<TAG>::B_method(TAG *A_object)
{
.
.
A_object->A_method(fileName)
}
The 1st method that is invoked above is A::someMethod
The problem is that when running the application the fgets makes the
application crash (the _cnt component has the value -1). When
debugging the application though everything works fine.
Your shown code has become a bit too pseudo.
There is no _cnt component and from what is
shown, there is no visible reason for the fgets()
call to fail with a fault.
It is common, when one has induced undefined
behavior, for that behavior to change when the
build settings change.
You may want to provide some real but reduced
code that duplicates your problem. Alternatively,
learn to modify your non-debug build so that you
can use the debugger and debug it.
--
--Larry Brasfield
email:
do***********************@hotmail.com
Above views may belong only to me.