List:MySQL++« Previous MessageNext Message »
From:Joel Fielder Date:November 17 2006 8:38am
Subject:Re: Compile Error/Code Issue
View as plain text  
I'm 100% sure that mysql++ is fine here.  Have you compiled and run the
example programs?  If so then it's safe to say that mysql++ is all setup
fine and that the problem is with your code.  I strongly suggest a c++
mailing list because you will get more people willing to help out and
this is becoming somewhat off-topic :)

More than likely this is caused by the fact that the compiler can't work
out which version of Connection you want.

By including mysql++.h you are getting mysqlpp::Connection, but you
bring it into global namespace with the using declaration, allowing you
to declare instances of mysqlpp::Connection without writing "mysqlpp".

Then, you forward declare another class called Connection.

As far as the compiler is concerned, you now have two classes, both
named Connection.  It has no way of working out which version of
Connection you actually want to use, so it works on the principle of
"find the nearest thing called Connection", which is your forward
declared class.  This has no definition so you can't instantiate or use
the object.  And so it fails.

May I refer you to this document:
http://www.possibility.com/Cpp/CppCodingStandard.html - this is a pretty
comprehensive document on c++ coding style but also has a lot of best
practice tips, including, "Don't place using namespace directive at
global scope in a header file. This can cause lots of magic invisible
conflicts that are hard to track."

Personally, I never use "using" because I like to be able to look at the
code and know exactly what's going on without having to guess, and
importantly I am guaranteeing never to run into these problems.  Look at
it from this point of view: have you spent less time working out what
the problem is than you saved by not having to type "mysqlpp::"?

Joel.

Thread
Problems with mysql and mysql++ examplesgary clark14 Nov
  • Compile Error/Code IssueFreyja16 Nov
    • RE: Compile Error/Code IssueJoel Fielder16 Nov
      • Re: Compile Error/Code IssueFreyja17 Nov
        • Re: Compile Error/Code IssueJoel Fielder17 Nov
  • Re: Problems with mysql and mysql++ examplesWarren Young16 Nov
    • Re: Problems with mysql and mysql++ examplesgary clark16 Nov
Re: Problems with mysql and mysql++ examplesgary clark16 Nov