Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 C++


  GCC is compiled with C++ compiler

On 15 Aug, 2012, GCC merged a patch--Merge from cxx-conversion branch . This means GCC will be compiled with C++ compiler in the future, it also means that GCC will be implemented using C++.You may have following two puzzles:Why does GCC turn to C++?Without C++ compiler, how can we compile C++ codes?Why using C++?In GNU's C++ Conversion, we can find this description in the background section:Whether we use C or C++, we need to try to ensure that interfaces are easy to understand, that the code is reasonably modular, that the internal documentation corresponds to the code,&n...

363,640 0       C++ GCC COMPILER


  Eight C++ programming mistakes the compiler won’t catch

C++ is a complex language, full of subtle traps for the unwary. There is an almost infinite number of ways to screw things up. Fortunately, modern compilers are pretty good at detecting a large number of these cases and notifying the programmer via compile errors or warnings. Ultimately, any error that is compiler-detectable becomes a non-issue if properly handled, as it will be caught and fixed before the program leaves development. At worst, a compiler-detectable error results in lost time while the programmer searches for a solution or workaround.The dangerous errors are the ones that co...

33,844 3       C++ COMPILER ERROR DETECTION


  Custom C++ exception class creation

In standard C++, we can use try catch to catch and exception when something goes wrong. These are some built in exception support in C++. By including the #include , we can now catch exceptions in C++ programs. This actually helps us on debugging our code and reduce the maintenance work.However sometimes if we want to create our own custom exception class. What should we do?We should include the #include line and then extend the exception class and implement some methods as you like. The general format is :#include using namespace std;class MyException:public exception{public:  &nbs...

31,489 2       C++ STD EXCEPTION CUSTOM EXCEPTION IMPLEMENTATION


  Using MySQL Connector/C++ with Visual Studio 2010

MySQL Connector/C++ is one of the latest connectors for MySQL, developed by Sun Microsystems. The MySQL connector for C++ provides an object-oriented application programming interface (API) and a database driver for connecting C++ applications to the MySQL Server.When we want to build a database application with C++ using Visual Studio 2010, we may use the MySQL Connector/C++, but sometimes we may encounter different errors, either compile or runtime error. After tried many times, I finally made my C++ program successfully connect to MySQL database with Visual Studio 2010. Here I share what I ...

30,600 1       C++ VS2010 MYSQL CONNECTOR VISUAL STUDIO 2010


  Save QWidget as image

Qt library is an excellent GUI library for C++ programmers developed by Nokia and now is an open source project. Often, we may use QPainter to draw strings, lines or images on a QWidget. We can override the QWidget's paintEvent() method when we want to use QPianter object to draw something on a QWidget.If we want to save the items drawn on QWidget as image for later reference, what can we do? We can save a QWidget as an image. Here is the code for achieving this:QPixmap pixmap(this->size());this->render(&pixmap);pixmap.save("test.png");Quite simple, right? Yes, these are all the code...

27,042 1       C++ IMAGE QT QWIDGET


  C++/CLR int to System::String^

In C++/CLR (for Microsoft), sometimes we need to convert int to System::String type or vice versa. The simple way is :From System::String^ to int int num= int::Parse(str); // System::String^ to intFrom int to System::String^System::String^ str = num.ToString(); // int to System::String^For all the other data types, similar ways can be adopted....

22,037 2       MICROSOFT C++ CLR SYSTEM::STRING CONVERT INT


  Must read C++ book list

Every programmer should read some books to enhance their understanding about the language before the start to practice. But some of us often wonder what books we should read and in what order. Some books may not be suitable for beginners and some books may cover the similar topics. Here I summarize a C++ book list we should read.Stage 1"Essential C++" : It is short but powerful and it can enhance our understanding of C++'s features.This book is specifically designed to bring you up to speed in a short amount of time. It focuses on the elements of C++ programming that you are most likely to enc...

19,285 0       C++ READ BOOK LIST EFFECTIVE C++


  Convert number to string in C++

Prior to C++11, there is no built-in function in C++ standard library which can be used to convert numbers such as interger and double number to string.  There are many ways which can convert number to string. Since C++ is C compatible, we can use itoa() function to convert an integer to C style string. But this one can only convert integer to string, not double. For different types of numbers, we need to use different functions.string s = string(itoa(a));Actually, we can also use stringstream in C++ to convert number to string.  Also, here since we want to convert different types of...

18,943 1       C++ CONVERSION NUMBER STRING