Click here to Skip to main content
15,881,173 members
Everything / Programming Languages / C++

C++

C++

Great Reads

by Dr. WPF
.NET 3.5 SP1 is here! It's time to break out your DirectX skills. This article provides the information necessary to get started using a new DirectX interop feature in WPF called D3DImage.
by Hatem Mostafa
Artificial Neural Network C++ class with two use cases: Counter and Handwritten Digits recognition
by Jeffrey Walton
Import and export Cryptographic Keys in PKCS#8 and X.509 formats, using Crypto++, C#, and Java.
by Hans Dietrich
XColorSpectrumCtrl displays a color spectrum that allows user selection, and provides APIs for color based on RGB and HSL color models.

Latest Articles

by Michael Chourdakis
An introduction to machine learning with working C++ code that trains a linear regression model.
by PJ Arends
Trace your function calls to the Output window.
by Ștefan-Mihai MOGA
Task Manager shows you the programs, processes, and services that are currently running on your computer. You can use Task Manager to monitor your computer’s performance or to close a program that is not responding.
by Mohammed Faci
How to leverage ChatGPT to Build an Automation Framework using the Page Object Model

All Articles

Sort by Title

C++ 

15 Oct 2012 by Cpp For All
finally like clause in C++
12 Feb 2011 by PrafullaVedante
Avoid using "if" with no code block parenthesis
10 Feb 2011 by Andrew Rissing
Always review all changes before submitting them. Especially, if using a global find and replace.
17 Feb 2011 by paladin_t
Whatever, I agree with you, it would be worse in C / C++ code using macros.Suppose you got a multiline macro like this:#define some_macro \ do_something_1(); \ do_something_2();And using this macro without parenthesis:if(...) some_macro;orfor(...) ...
15 Feb 2010 by The Zetta
Sometimes, Visual c++ users see a pretty confusing error message when they compile or build their projects. the error message says :fatal error C1083: Cannot open precompiled header file: 'filename.pch': No such file or directorymy solution was :In VS, go to Project->Options, set the...
21 Sep 2010 by GPUToaster™
A simple way to detect bitness of an OS Programatically. (C# and C++ examples given)
13 Oct 2010 by Reinhard Ostermeier
In .NET 4.0, you can also use the new System.Environment.Is64BitOperatingSystem and System.Environment.Is64BitProcess
19 Sep 2010 by Aescleal
In C++ you can use the size of a pointer to work out what sort of process you're running in:bool is_64_bit(){ return sizeof(void *) == 8;}This has got the advantage of being portable and you don't have to call any OS functions.You can do something similar in C - just return...
20 Sep 2010 by a_pess
To check 64Bit Operating system in VB.NET,Public Shared Function is64BitOPeratinSystem() As Boolean Return (Marshal.SizeOf(IntPtr.Zero) = 8)End Function
5 Aug 2011 by The_Mega_ZZTer
Version check is wrong. It happens to work correctly only because no minor versions of Windows 5 were released after 5.1 (AFAIK... are Windows Server 2003 and Embedded XP and Media Center XP still 5.1?). A theoretical version 5.2 would fail the check. I submit the following...
29 May 2012 by Nitin K. Kawale
3D Vector Graphics class.
19 Jun 2011 by Rimon Orni
Code injection cave for 64 bit processes
13 Oct 2010 by Ajay Vijayvargiya
Wouldn't be easier if you just pass a simple function to your favourite thread creation function? Read on!
19 Oct 2010 by federico.strati
I always use a somewhat different approach, here is a class"consumer" that has embedded the thread call in a member function,the member function runs a virtual call, hence the derived classesmay implement functionality as well as passing arguments asmember data of the class. Maybe you're...
13 Feb 2018 by Laurie Stearn
Code attached to a 2003 article updated for Visual Studio 2017.
17 Mar 2014 by Indivara
A very simple class that allows you to easily lock blocks of code from multi-threaded access.
U 9 Apr 2024 by PJ Arends
Trace your function calls to the Output window.
10 Jun 2010 by Software_Developer
set the variable count_down_time_in_secs in seconds for desired count down time.The Code is self explanatory.1 minute = 60 secs5 minutes = 60x5 secs30 minutes =60x30 secs1 hour = 60x60 secs#include #include int main (){ unsigned int...
10 Jun 2010 by Anshul R
You can simply use the sleep() function in dos.h in a loop and print it!
14 May 2014 by Gregory Morse
A full-featured Z80/8085 assembler in C++
28 Jun 2016 by JohnX2015
This is a cross-platform general C++ engine, including a general runtime and a reflection engine.
11 Mar 2023 by honey the codewitch
Initializing the ESP LCD Panel API is a chore. Here's some boilerplate code to make it easier.
16 Dec 2015 by Tim ONeil
INI-style properties for C++ Embedded/Applications on Linux
26 Jul 2010 by SpaceSoft
A little class to help you avoid memory leaks
1 Aug 2010 by Aescleal
Combining a smart pointer with a collection we can get all the functionality that the original author wrote a custom class for, and a bit more:typedef std::vector> garbage_collector;Er, that's it. So how would you use this? Say you wanted to use character arrays as...
7 Jul 2014 by Michael Bergman
Using Windows Communication Foundation to build a simple web server
26 Aug 2013 by paladin_t
A Mimetic C# Style Multicast Event Implementation with C++
5 Feb 2018 by Yesy
Provide a multiple-async-waiting operation management pattern for Android
10 Aug 2022 by Mukit, Ataul
Using the filesystem as a repository for a circular buffer for achieving persistence of data
16 Jan 2016 by Mathew_wwx
This tip will introduce a library written in C++ that wraps up a 2d polygon triangulation algorithm with time complexity of O(N*logN), the algorithm works on both self-intersected and non self-intersected polygons.
20 Mar 2013 by cocaf
How to show progress in a Boost test application.
11 Nov 2010 by Software_Developer
A simple program to calculate quadratic equation with.Input MUST have the format:AX2 + BX + C = 0EXAMPLE: input the equation 2X2 + 4X -30 = 0 as:A= 2 B= 4 C= -30The answers for AX2 + BX + C = 0 should be 3 and -5.x1=3x2=-5 bool solver(float...
20 May 2010 by ReymonARG
#include #include #include "Raiz_Cuadratica.h"int main(){ // float xx = 1; float x = 1; float i = -12; RaizCuadratica *lala = new RaizCuadratica( xx, x, i ); RaizCuadratica::sRaiz raiz = lala->GetRaiz(); printf( "x1 = %f || x2 = %f\n\n",...
8 Nov 2010 by Anshul R
Simple and prints imaginary roots too!float a,b,c,x1,x2,d,dsq;printf("ax^2 + bx + c = 0");printf("\nEnter a,b,c separated by commas : \n");scanf("%f,%f,%f",&a,&b,&c);d = b*b-(4*a*c);if(d>=0){dsq=sqrt(d);x1 = (-b+dsq)/(2*a);x2 = (-b-(dsq))/(2*a);printf("\nRoot 1 : %f\nRoot 2...
7 Nov 2010 by TomSeaton
#include
10 Nov 2010 by federico.strati
The correct way to solve quadratic equations is none of the above. For the correct algorithm as applied in the following function, seenumerical recipes in C and the Wolfram site at http://mathworld.wolfram.com/QuadraticEquation.html#include bool quadratic(double a, double b,...
15 Nov 2010 by Michael Waters
I am reposting this because I accidentally deleted my first post.The solution is presented as a pair of complex roots, unless a == 0, in which case the equation is linear and returns a single complex(real) root.If a == 0 and b == 0, the function fails.Given a complex type, replace...
9 Nov 2010 by YvesDaoust
// Real solutions of the quadratic equation A x^2 + B x + C = 0// Returns two roots (possibly identical) in increasing order, or nonebool Quadratic(double A, double B, double C, double R[2]){ if (A == 0) { // Linear, impossible or degenerate, cannot find two roots ...
16 Nov 2010 by Alain Rist
I prefer this :) #include #include #include #include static const double bad_double = std::numeric_limits::quiet_NaN();class QuadSolver{ static bool IsZero(double val) { return (val == 0) || (fabs(val)
1 May 2013 by Mohibur Rashid
Title says it all.
13 Jun 2014 by Jason Stern2
This is a simple Windows example using the Chromium embedded framework 3.
29 Mar 2019 by Rick York
This is a simple worker thread class that allows when to use a member function as the thread function.
21 Apr 2014 by Marco Bertschi
Sktech for a generic queue which can handle tasks, process them and report the result
30 Apr 2012 by Nippey
This is a TCHAR alternative for "A Small Class to Read INI File"
5 Jan 2011 by paladin_t
A String & Number Compatible ID Class in Native C++
24 Jan 2011 by CodeRichardWong
Especially useful in some situations. Sometime may be confused inside, is it?(id4) assigned double's result is diff.If you add this:id1 = id4;The answer is...better to prepare one more conversion.have a Try~
4 Mar 2021 by Southmountain
glaux.h header file & glaux.lib can be replaced by freeglut.h & freeglut.lib
26 Mar 2021 by Southmountain
Some quick configurations to get MFC support for console application
25 May 2015 by osy
Proper implementation of a signal handler
19 Apr 2011 by Mukit, Ataul
A simple implementation of alpha blending technique displaying the basic mechanism behind it
19 Apr 2011 by Mukit, Ataul
SledgeHammer didn't help, so I had to do it myself... here it is again - a super fast improved algorithm compared to the previous one and with no setpixel and getpixel :)void AlphaBlend(CDC* pDC, int xDest, int yDest, int nDestWidth, int nDestHeight, CDC* pSrcDC, int xSrc, int ySrc, BYTE...
23 Jun 2020 by Greg Utas
Replacing its erase() function
4 Oct 2012 by Ritesh_Singh
C++ code to connect/access DB2 database using DB2 call level interface(CLI)
19 May 2013 by Amit Deshmukh 1010
Accessing class object present in exe from explicitly loaded DLL using Inheritance and virtual function.
8 Dec 2022 by Alexey Shtykov
Activate a particular document window in MDI application via MFC/C++
7 May 2014 by Gregory Morse
Activating WRL audio interfaces in native C++
3 Mar 2010 by hjgode
The following is a nice? sample for an automation task. This batch will be executed every time a device connects to your PC via ActiveSync. You will need the itsutils.As you can read, the batch (script) first tries to check, if it has already been run on the device. This is done by looking...
29 Oct 2015 by Francis Xavier Pulikotil
Enable passing an argument by reference, to a function which expects an argument of a different type.
29 Jun 2016 by Priyanka Sabharwal81
Adapter Design Pattern in C++
1 Apr 2015 by Lantert
Add Excel style filter function to Chris Maunder's CGridCtrl
15 Oct 2014 by Arthur Caputo
Tutorial on setting a false transparency onto your button's edges.
4 Aug 2013 by Ashish Ranjan Mishra
How to add sub menus dynamically, adding event for them and also retrieving the menu name on click event of individual sub menu
22 Jan 2015 by jit_knit
Adding Map support in Dashboard for executive reports
1 May 2021 by Greg Utas
A function may only return from its last line!
10 Jan 2014 by Vedat Ozan Oner
A library for 5-button analog keypad
14 Mar 2019 by Martin Vorbrodt
Advanced thread pool
3 Jul 2014 by Rob Kraft
A method is idempotent when the same input(s) always return the same output.  This method is idempotent: This method is not idempotent: When adding methods to classes, many developers spend little time deciding if the method should be idempotent.  Making use of the properties in the class causes the
27 Dec 2012 by WebMaster
Some simple examples of how to apply affine transformations in computer graphics.
1 May 2017 by Arthur V. Ratz
This tip/trick introduces the basic ideas on how to avoid memory mismatched allocation/deallocation issues detected by Intel® Inspector XE for Visual Studio 2015
5 Jun 2012 by Abed AlSayed
AlSayed ColorBar is a TrackBar best for professional color picker, like the one used in Adobe Photoshop.
20 Aug 2023 by Ștefan-Mihai MOGA
How to download files from an HTTP server.
14 Feb 2016 by Jigar_Patel
Amazon S3 lib for uploading file in C++ using VS2010
22 Oct 2011 by Basil_2
A few uncommon code sample
1 Nov 2011 by User 40411
Try this one://Can we print all integers from 1 to 30??/int x = 0;while (x
11 Jan 2015 by davrossi
This is an alternative to LoadString for accessing string resources.
3 Aug 2021 by BernardIE5317
On certain occasions, Visual Studio does not indent as intended so here is an awk program which does the trick.
22 Jun 2022 by Stephane Capo
C++ optimization for map using string key among others
15 Mar 2016 by cruppstahl
Describes algorithms for integer compression, introduces a few libraries and shows how to use them
26 May 2014 by Alexander Golde
Analyzing Syslog files can be easy...
16 Mar 2019 by Martin Vorbrodt
AoS vs SoA performance
7 Sep 2022 by Bruno van Dooren
Symantec can cause valid applications to crash and be gone without a trace
18 Oct 2014 by Marco Bertschi
A short guide on how you can style and customize the appearance of you QML controls in a CSS-like way
23 Sep 2015 by Bartlomiej Filipek
How to apply the strategy pattern to a problem while designing a class hierarchy. What are the pros and cons of this approach?
27 Dec 2020 by Steffen Ploetz
Step-by-step instructions and source code snippets for inserting a bitmap (or a section of it) into an icon image.
30 Apr 2015 by webmaster442
Some useful Arduino tips & tricks
13 Aug 2015 by Joren Heit
Easy, compile-time manager of EEPROM variables
13 Aug 2015 by Joren Heit
Easy, compile-time manager of EEPROM variables
28 Mar 2011 by jean Davy
std::string source = "Hello World";std::wstring result( source.begin(), source.end() );One coding line less !
13 May 2011 by blytle
also since _bstr_t's have operator (char *) and operator (wchar_t *) if you have included comutil.h, you can use it to do your conversion.char * source = "this is my source" ;_bstr_t converter_temp(source) ;wstring target ;target = wstring(converter_temp) ;... and the other way...
14 May 2011 by Philippe Mori
inline std::wstring AsciiToUnicode(std::string text){ // Could do some DEBUG check here to ensure it is really ASCII. // Also, if in the future, it is found, it is not the case, // it would much easier to update code. // Same as jean Davy here... return...
9 Feb 2015 by Sohail Fareedi
Page Framework Initialization - Page.Init
14 Mar 2019 by Martin Vorbrodt
Atomic blocking queue
2 May 2013 by Ihab ramadan
Demo illustrates how to make augmented reality program using irrlicht and newton
1 May 2010 by Ajay Vijayvargiya
Visual Studio 2010, for Visual C++ projects/code, now supports auto complete feature for #include statement too!Just type in #include directive followed by " or
13 Oct 2012 by ed welch
Automatically stepping over STL
30 Dec 2014 by Roi Azulay
An automation solution using Arduino
1 Mar 2024 by Member 10912276
How to control game elements based on predefined conditions