Gary wrote:
> Hi friends!
> I'm using Visual C++ 2008 and "CryptoPP 5.5.2" version!
> I've built the code below successfully:
>
> [snipped]
>
> Then I decided to remove scope sections("CryptoPP::" and "std::") form
> code, such below:
>
> [snipped]
>
> And then got 35 errors as following:
>
> [snipped]
>
> Now my question is that why sould the codes using "CryptoPP"
> library,have this scopes in
>
> themselves certainly?
> Though we use necessary "Header Files" and have added this library to
> Visual studio
>
> environment,why should we maintain these scopes("CryptoPP::" and
> "std::") in the codes
>
> again?
> Why is this work necessary?
>
This is a good design decision made by the library authors to put all
their identifier names (variables, classes, functions, types, etc.) in
their own unique namespace. This is done to avoid "namespace pollution."
If you want to make your life easy, you can "use" the namespaces "std"
and "CryptoPP" in your programs like this:
// Start of Code
#include "stdafx.h"
#include "rsa.h"
#include "osrng.h" // PRNG
#include "hex.h" // Hex Encoder/Decoder
#include "files.h" // File Source and Sink
using namespace std;
using namespace CryptoPP;
int main(int argc, char* argv[])
{
...
// End of Code
However, this is usually only useful (or applicable) is smaller
projects. You certainly should try to avoid this in your own header files.
> Thank you!
> Gary
-yzt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---