C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have an issue using an ADOQuery component with C++ builder.
If I execute a simple query "select * from Frames where FrameID = 1934411" the result is no record returned when Frames is a view.
However, if I copy the entire view contents into a table and then run the query against the table then the Record is found ?
The database is a Microsoft SQL Server version 12.0.5207.0

If I run the query on the view or the table using Microsoft SQL Server Management Studio then in both cases the record is returned.

Can this be fixed to use the view ?
Cloud Class® Course: SQL Server Core 2016
LVL 12
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Hi All

I have a query regarding  memory related issue I am getting in one of my web service.
I have made a service using c# which is calling C++ third party dll. While running the service I am getting below error.

"Memory gates checking failed because the free memory is less than 1%."

After going through in deep, i found that there is some memory leak issue exist in the dll.
do we have any way by which-

1. we can release the used memory by c++ dll in c#?
2. Within service or using IIS, can we put a check by which how much free memory, service is using we will get to know and then and there can do the forceful recycle?

any idea will help.

Hi I am trying make a deep copy of the structure below which will contain the decoded video frames and copy to a new element in a vector without each previous element being overwritten.
The structure below is being populated as the memory in debug mode is increasing as expected with each pass of the while loop.
struct YUV_Buffer
mfxFrameSurface1  *mSurface;
YUV_Buffer(mfxFrameSurface1 *pBuf = { 0 })
    : mSurface(new mfxFrameSurface1[sizeof(mfxFrameSurface1)])
    memcpy(mSurface, pBuf, sizeof(mfxFrameSurface1));

YUV_Buffer(const YUV_Buffer& YuvBuf) 
 : YUV_Buffer(YuvBuf.mSurface)  

YUV_Buffer& operator = (YUV_Buffer YuvBuf) {

    std::swap(mSurface, YuvBuf.mSurface);
    return *this;

~YUV_Buffer() {

Open in new window

I am calling the structure and copying the elements into the vector with each iteration of the while loop "mfxFrameSurface1 pVPPSurfacesOut[nSurfIdxOut]" contains all the information regarding the decoded video frame I need to copy pVPPSurfacesOut[nSurfIdxOut] to the vector mBuffer.push_back(root) using a deep copy so the data that the pointers in the structure are pointing to are also copied but what is actually happening is the last frame processed is overwriting all previous elements in the vector. Each time the loop passes like this: I have removed the code that is decoding each frame as its no relevant I just need to work out why the elements are getting overwritten in the vector
std::vector<YUV_Buffer> mBuffer;
YUV_Buffer root(pVPPSurfacesOut[nSurfIdxOut]);

Open in new window

each iteration of the while loop populates pVPPSurfacesOut[nSurfIdxOut] structures which contain pointers with video information like height width buffersize … and the video data its self in a NV12, YUV420 colour space, I need to access each frame from the vector mBuffer but when I try to access the vector mBuffer[0]… Im getting the last frame copyed to the vector.

Regards Nigel
Hello , i've the following routine :
int Asio_Send_Pck(int iSendt,int Lsocket,char * Lbuff,int Len)


    LSession* iTempLSession = reinterpret_cast<LSession*>(Lsocket);

    boost::asio::async_write(iTempLSession->socket() ,

                              boost::asio::buffer(Lbuff, Len),







    return 0;


Open in new window

But i always get an Invalid Arguments .

Here's my Lsession class :

class LSession
  int readlen;
  int userdata;
  int deadtime;
  enum { max_length = 1024};
  char data_[max_length];
   LSession(boost::asio::io_service& io_service)
        : deadtime(0), socket_(io_service)
        readlen = 0;
        userdata = 0;


  tcp::socket& socket()
    return socket_;

  void start()
    socket_.async_read_some(boost::asio::buffer(data_, max_length),
        boost::bind(&LSession::handle_read, this,

  void handle_read(const boost::system::error_code& error,
      size_t bytes_transferred)
    if (!error)
	  if(Callback_readdata!= NULL)

Open in new window

Hello ;
I want to design a GUI.my application is as bellow :
while compiling my program , a first interface is displayed : it is for user authentication, by validating this step ,another interface is displayed :this interface is devided into two screen  show(Splitter with two column) the second interface is combined : a menu , and a tree view .by clicking in one item , a data and controls are shown in the right of interface.
To do this application , did I need for SDI or MDI
Also how to navigate between the two interfaces (the authentication interface and the second interface), should I use two Documents ?
For the first interface , I just want a simple area which display the logo of company and an edit control for tapping the Password. but since compiling the project ,always a classic dialog box is shown (made by Microsoft ).
Is there any idea which clarify my needs.
Hi I am having problems with a vector that I am populating each element from a structure but the elements seem to be getting partially over written Here is what I am drying to do
struct YUV_Buffer
	void *pCacheBuf;
	int frameID;
	int height;
	int width;
	YUV_Buffer() { pCacheBuf = NULL, frameID = 0, height = 0, width = 0; }

Open in new window

        YUV_Buffer *nBuffer;
	vector<YUV_Buffer> mBuffer;

Open in new window

Implementing the vector array
Here I create a new instance of the structure from within a while loop each iteration of the loop a new video frame is passed to the structure and then added to the vector as a new element
                        YUV_Buffer *nBuffer = new YUV_Buffer();
			nBuffer->frameID = pmfxInSurface->Data.FrameOrder; // frame number
			nBuffer->width = pmfxInSurface->Info.CropW;                 // frame width
			nBuffer->height = pmfxInSurface->Info.CropH;                // frame height
                        nBuffer->pCacheBuf = pSysFrame;                                     // YUV video buffer
                        mBuffer.emplace_back(*nBuffer);                                      // add structure to vector array
                        SAFE_DELETE_ARRAY(nBuffer);                                            // delete structure

Open in new window

I then for testing that the data in the vector element is correct I do the following with OpenCV
each iteration of the while loop cnt is implemented by 1 and mBuffer[cnt].pCacheBuf) contains the video buffer data
                  cv::Mat picYV12 = cv::Mat(pmfxInSurface->Info.CropH + (pmfxInSurface->Info.CropH / 2), pmfxInSurface->Info.CropW, CV_8UC1, mBuffer[cnt].pCacheBuf);
		  cv::Mat picBGR;
		  cv::cvtColor(picYV12, picBGR, CV_YUV2RGBA_NV12);
		  cv::Mat test;
		  cv::cvtColor(picBGR, test, CV_BGRA2RGBA);
		  cv::imshow("MyVideo", test);

Open in new window

This code works and OpenCV display the video frame in its own window perfectly my problem is I need to load all video frames into the vector array and be able to access each frame individually from the vector but what is happening is that the last element in the vector seems to be over writing all previous elements so I end up with 3000 elements in the vector all containing the last video frame buffer. It seems that its only the buffer array that is getting over written as the frame numbers are correctly assigned to each element.

I then need to call each frame from the vector in any order I wish, I have been trying to do it this way

Open in new window

I am trying to open a file dialog box but stumble to in to a problem.
And i al ready #include <commdlg.h>

C:\dev\test_menu/main.cpp:146: undefined reference to `GetOpenFileNameA@4'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1

#include <windows.h>
#include <stdio.h>
#include <commdlg.h>

void AddMenus(HWND);
void open_file(HWND);
HMENU hMenu;

int ID_Save;
int wp;

const char g_szClassName[] = "myWindowClass";

        case WM_COMMAND:

            case 2:

            case 3:

            case 5:
            SendMessage(hwnd, WM_CLOSE, 0, 0);


        case WM_ACTIVATE:
        case WM_CLOSE:
        case WM_DESTROY:
        return DefWindowProc(hwnd, msg, wParam, lParam);
    return 0;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,  LPSTR lpCmdLine, int nCmdShow)
    HWND hwnd;
    MSG Msg;
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = 

Open in new window

We would like to find a way to automatically convert an excel workbook into c++ code.
The following tool apparently does that (calc4web) however it generates a compiled .dll intead of C++ code.
We want to be able to reuse and enhance the c++ code.
Anyone used this before? Are there any other out of the box solution out there ?
If not, is there a way or a tool  to map the entire workbook so that we can follow it like a blue print and then convert it to c++
Any ideas or solutions would be very helpful
I have an application which implements a state machine based on StateForge (StateBuilderCpp) generator. A state machine is defined as asynchronous and uses boost in the generated code:

<settings asynchronous="true" library="boost">

Open in new window

Actions (implemented methods) are very fast but are called frequently - events are triggered with 10ms intervals. State machine uses boost ioservice.

I run the application on a single core atom processor. Generally that pc is strongly utilized by others applications and I have noticed that sometimes when a cpu has a high iowait a dozen or so events are queued. Is it coincidence ? How to explains such behaviour ?
I create my tree using the code a bellow :
//Create my own Tree(Items + Sub Items)
BOOL CIntAccDlg::OnInitDialog()
      HTREEITEM hMétrologie, hSurveillance, hHisOuverture, hHisDépassementTempérature, hHisMiseTerre, hLogResetsHis , hMetrologieLegale,hRelais, hCourbeDeCharge, hGlissProgrammé ,hHorodate, hFacturation, hStructureActive, hGlissPeriodique,hStructurePassivective, hJoursFériés, hCalendrierTarifaire, hInstantanée, hMetrologieNonLegale, hEnergie, hMoyenne,hMaximas,hContrat,hExursionTension
      , hCoupures,hCommunication, hCléAESGCM, hCléCrypAUTHGCM, hParPhyPortLocal, hHDLCPortLocal, hParPhyPortSerie, hParHDLCPortSerie, hImporter, hExporter, hImprimer;
      hMétrologie = m_treeCtrl.InsertItem(_T("Métrologie"), TVI_ROOT);
      hMetrologieLegale = m_treeCtrl.InsertItem(_T("Métrologie Légale"), hMétrologie);
      hMetrologieNonLegale = m_treeCtrl.InsertItem(_T("Métrologie Non Légale"), hMétrologie);
      //Métrologie légale
      hInstantanée = m_treeCtrl.InsertItem(_T("Instantanées "), hMetrologieLegale);
      hEnergie = m_treeCtrl.InsertItem(_T("Energies "), hMetrologieLegale);
      //Métrologie Non légale
      hMoyenne = m_treeCtrl.InsertItem(_T("Moyennes "), hMetrologieNonLegale);
      hMaximas = m_treeCtrl.InsertItem(_T("Maximas "), hMetrologieNonLegale);
      hContrat = m_treeCtrl.InsertItem(_T("Contrat "), hMetrologieNonLegale);
      hExursionTension = m_treeCtrl.InsertItem(_T("Excursion de tension "), hMetrologieNonLegale);
      hRelais= …
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Hello ,
I create a menu "config" .I want to open another dialog box when I click in the menu "Config".
I make a function added to Menu ID : W_Command
Then I call it in the principal dialog box :InAccDlg ,as it shown in the code as bellow , while compiling ,the called dialogBox wasn't shown .
My code is as bellow :

void CIntAccDlg::OnIdrMenu1()
      CConfigDlg ConfigDlg;
Is there any problem !
I've read the following post https://www.experts-exchange.com/questions/28910764/Implementing-a-ResolveEventHandler-in-C.html
and I'm experiencing the exact problem, but couldn't solve it.
I'm using pure c++ (no C++/CLI)

Any help would be appreciated
Hello , I want to display two edit controls by clicking on button .
in te first one , the two edit control are hiding . just by clicking a button , those two edit controls will be shown .
Any help please !
I want to make sms app (short message) for android using c++ builder, so help me please
Hello everyone, is there code to create your console, can you somehow link it to using commands from a file and pressing the enter key?
c ++

    #include <log.h>
    #include <cvar.h>
    #include <option.h>
    #include <stream.h>
    #include <xmpp.h>
    #include <xmpp_kb.h>
    #include <session.h>
    #include <threads.h>
    #include <lang.h>
    #include <tools.h>

    int main(int argc, char *argv[])
        const char *exe_path = argv[0];



        if (cvar.g_language != NULL)
            char *path;

            FORMAT(path, "kfg/dang/%s.kfg", cvar.g_language);

        char *token = NULL;
        char *online_id = NULL;
        char *cmdline = NULL;

        option_parse(argc, argv, &token, &online_id, &cmdline);

        /* Start */

        if (isatty(STDOUT_FILENO))

        /* End */



        int wfs = stream_connect(cvar.online_server,

        if (wfs > 0)
            session_init(wfs, online_id);


            xmpp_connect(token, online_id);

            threads_run(exe_path, cmdline);



what is the best tool to do profiling for c++ multi threaded server daemon on Linux?

Complied program with -pg and the tried with gprof/gmon.out. Couldn't find call graph as per functions mentioned in my program. It has shown all low level api's call graph like string internals, memory allocations..etc.

Can someone suggest how to get call graph from gmon.out for multi threaded server daemon.

Any other tool(s)?
I had this question after viewing Remote App failed to launch using MSTSCLib API.
I have to launch an application remotely. with the below lines of code able to connect remote  desktop. but not able to launch remote application
m_RemoteAppobj = m_RDPClient.get_RemoteProgram2();
void CTestRdpNECTIDlg::OnConnectedMstscax1()
            LPCTSTR lpExecutablePath = L"C:\\Windows\\System32\\notepad.exe";
            LPCTSTR lpworkingdirectory = L"c:\\";
            int n=m_RDPClient.get_Connected();
            m_RemoteAppobj.ServerStartProgram(lpExecutablePath,L"",lpworkingdirectory,false ,L"ARGS",false );
            wchar_t buf[256];
                  buf, (sizeof(buf) / sizeof(wchar_t)), NULL);
I have three base Classes {Player,Weapon,Game} and one inherited Class Warrior from Player.

I would like to code function addWizard using function .I thought of dymanic casting,but I'm not sure how to start. Any help would be appreciated.


*Each index in playersArray consists of pointers to class Player.

*If a player's name in a given index,oplayersArray equals to empty string, it indicates there's no player yet.

*I added the constructors of each Class Game and Player(the default only) and Wizard.

void addWizard(string const& playerName,string const& weaponName,
                       Target target, int hitstrength,int range);

GameStatus Game::addPlayer(const string playerName, const string weaponName,
                               Target target,int hit_strength)
    {   int count=0,place=0;
            throw GameFull();
        for(int i=0;i<maxPlayer;i++)
            if(playersArray[i]->getPlayerName()!="" &&
                throw NameAlreadyExists();
            if(playersArray[i]->getPlayerName()==""&& count==0)
        Weapon newWeapon(weaponName,target,hit_strength);
        Player newPlayer(playerName,newWeapon);
        return SUCCESS;

Open in new window


class Game {
        int maxPlayers;
        Player **playersArray;

class Player {
        string player_name;
        int level;
        int strength;
        Weapon player_weapon; }

//the inherited Class 

class Wizard : public Player {
    int range;
    Wizard (string const& name, Weapon const& weapon, int range);

Open in new window

Game::Game(int maxPlayer)
: maxPlayer(maxPlayer),playersArray(new Player*[maxPlayer])
    for(int i=0;i<maxPlayer;i++)
        playersArray[i]=new Player;


Wizard::Wizard(string const& name, Weapon const& weapon, int range) :
    if (weapon.getTarget() == LIFE){
        throw IllegalWeapon();
        throw InvalidParam();

Open in new window


is there a way to set gdb filename:line_number such that the filename is a path?

Cloud Class® Course: MCSA MCSE Windows Server 2012
LVL 12
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

std::function as a parrameter in delegate constructor
      i want to know why control does not goes to AB() if i passed abc(AB) in main() as control goes for initialization of i as 10 when abc(10) is passed

class abc { int i;

    std::function<void(void)>func = nullptr;
public: abc(){}

    abc(int i):i(i){}
void AB() { cout<< "fun_AB"; }

int main() { abc(AB); abc(10); }

Open in new window

Good day! I'm trying to display an image in the Picture Control in the MFC with pixel data. Tell me what's wrong.

image = new DicomImage(str);
		Uint8 *pixelData = (Uint8 *)(image->getOutputData(8));
		if (pixelData != NULL){
			int w = image->getWidth();
			int h = image->getHeight();

			HBITMAP hBitmap = NULL;

			bmih.biSize = sizeof(BITMAPINFOHEADER);
			bmih.biWidth = 1024;
			bmih.biHeight = -512;
			bmih.biPlanes = 1;
			bmih.biBitCount = 8;
			bmih.biCompression = BI_RGB ;
			bmih.biSizeImage = 0;
			bmih.biXPelsPerMeter = 10;
			bmih.biYPelsPerMeter = 10;
			bmih.biClrUsed = 0;
			bmih.biClrImportant = 0;

			ZeroMemory(&dbmi, sizeof(dbmi));  
			dbmi.bmiHeader = bmih;
			dbmi.bmiColors[0].rgbBlue = 0;
			dbmi.bmiColors[0].rgbGreen = 0;
			dbmi.bmiColors[0].rgbRed = 0;
			dbmi.bmiColors[0].rgbReserved = 0;
			void* bits = (void*)&(pixelData[0]); 

			// Create DIB
			HDC localDC = ::GetDC(NULL);
			hBitmap = CreateDIBSection(localDC, &dbmi, DIB_RGB_COLORS, &bits, NULL, 0);
			if (hBitmap == NULL) {
				::MessageBox(NULL, __T("Could not load the desired image image"), __T("Error"), MB_OK);

			unsigned char* dest = new unsigned char[w*h];
			dest =	(unsigned char*)bits;
			const unsigned char* src  = pixelData;
			for (int j=0; j<w; j++){
				for (int i=0; i<h; i++, src++){
					*dest++ = *src;
					*dest++ = *src;
					*dest++ = *src;


Open in new window

I am making a Doodle Jump game in c++ using sfml,
I started building the umlaut and decided to go with a STRATEGY pattern. I don't really know if this is the right choice.
I basically got to a point where I don't know how to continue,
please if someone could take a look at my UML and tell me what they think it will be greatly appreciated.

I have a DLL that is simply using some pretty common code to count files in a directory. On all our test computers, and 98% of people using it, there is no problem. But a few people experience a crash to desktop from this code. I am looking for some possibilities of why this could happen in these isolated cases.

Here is the code:
int FMSGaugeCallback::getFltPlnsInFolder(wchar_t szPath[MAX_PATH])
	WIN32_FIND_DATA		ffd;
	wchar_t				szFileName[MAX_PATH];
	DWORD				dwError = 0;
	wchar_t				szError[255];
	wchar_t				szDir[MAX_PATH];
	int					nLen = 0, nDir = 0, nCount = 0;

	if (!PathIsDirectory(szPath))
		return 0;

	swprintf(szDir, sizeof szDir,  L"%s*.pln", szPath);
	hFind = FindFirstFileW(szDir, &ffd);								// Open filefind
	if (INVALID_HANDLE_VALUE == hFind)								// if process fails record error
	{																// and discontinue function
		dwError = GetLastError();
		swprintf(szError, sizeof szError, ERR_SEARCH_FLT_PLNS, szPath,getLastWinError(dwError));
		return 0;

		if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)					
			nDir++;															// the flight plan array
	} while (FindNextFileW(hFind, &ffd));

	FindClose(hFind);												// Close filefind
	return nCount;

Open in new window

It is crashing in the do while loop, not at FindFirstFile.

Any ideas?
ardunio on board memory manipulation have a arduino mega now what is the best way to do the following, i want to have the program running and then update the array on board the arduino with out reloading the program, so lest say i have an array with 10 numbers and depending on the feed back from the card i am going to change location #4 of the in the 10 mem locations that i have set up how is the best way to do this please from the code running on the pc , would i access the arduino then the mem location and go from there, any ideas in this correct direction would be helpful
I had this question after viewing Explorer.exe crashing.
Hi, I have a simular issue on Windows 2016 Server RDS. I however do not have Microsoft Visual C++ 2008 installed but I do have the x86 and x64 versions of 2010 and 2012 installed. Do you suggest that is is a general issue with the Microsoft Visual C++ software of specific for Microsoft Visual C++ 2008?

The program iexplore.exe version 11.0.14393.2007 stopped interacting with Windows and was closed. To see if more information about the problem is available, check the problem history in the Security and Maintenance control panel.
 Process ID: a54
 Start Time: 01d3ec5f951cd3ff
 Termination Time: 8
 Application Path: C:\Program Files (x86)\Internet Explorer\iexplore.exe
 Report Id: e0176242-5852-11e8-90fe-001dd8b74bda
 Faulting package full name:
 Faulting package-relative application ID:






C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.