Pointers and Refences
I'm working on a simple set of classed to represent predicate logic. While I was writing the first few bits I ran across something strange.
My Particle class has a copy constructor defined as:
When I passed (as a random test) a pointer to this constructor it worked perfectly instead of causing the expected compiler error.
Particle(const Particle& p)
I tried writing a skeleton class to reproduce the effect (called A in the files) so I could post it here for explanations but this class causes the compiler to produce this error
I then tried the same thing with the assignment operator and obtained exactly the same results: Particle works and A fails.
main.cpp: In function `int main()':
main.cpp:63: error: no matching function for call to `A::A(A*&)'
main.cpp:11: note: candidates are: A::A(const A&)
main.cpp:7: note: A::A()
Below are links to the source files. I didn't post the directly because it's rather long.
I just realised I forgto to include the settings.h file which is only 2 #defines:
if #include "settings.h" is removed the code will still work except for the commented out test() function, just without the debug output
My guess is that it is converting the pointer to a bool and using the constructor for Particle that takes a bool. If you comment out that constructor it would probably not work any more.
You are right. It should have been obvious from the debug output.
Thanks, I've spent far too much time on this.