Thanks Bazzy
I have discover what is the reason of the error.
I have w_debug into a functions with 'const' sufix.
Now I have a doubt about the functionality of const functions.
Are related with a faster and powerfull program?
(That is to say, the code compiled are better if you write const variables and functions ?)
Can you give me a last help ?
Thanks
const functions are needed when you have to provide those functions for a const object or reference.
A const object may not be really useful but a const reference is.
When you have a large object, it's good practice to pass it to functions by const reference ( to avoid an expensive copy ), this const reference can only execute const method so you need to properly const-overload your member functions.
eg:
struct dummy_vector
{
int *buffer; // this would be a dynamic array, copying a dummy_vector object means copying the array - expensive
// ... imagine some expensive copy-constructor implemented here ...
int& operator[] ( int i ) // non-const method, can modify the object but can only be called by non-const objects
{
return buffer[i];
}
constint& operator[] ( int i ) // const method, cannot modify the object but can be called by const objects
{
return buffer[i];
}
};
void foo ( dummy_vector v ) // dummy_vector passed by value, expensive copy
{
cout << v[0]; // calls the non-const overload
}
void bar ( const dummy_vector& v ) // by const reference, no copying
{
cout << v[0]; // calls the const overload. It accesses the object but you are sure that it cannot be modified
}
In the code above, foo is much less efficient than bar because of the expensive copy of dummy_vector. bar can only work if dummy_vector is const-correct ( which means that methods that don't modify the object are declared as const )
Of course you can't have only const methods in a class, some of them would modify the object