c++

PHP Communication with C++ Application

I have been searching Google for a while, but the problem I am running into is I am not exactly sure what it is I need to be searching for. (Searching for PHP C++ communication doesn't seem to be what I need) I am basically developing a c++ plugin for a game server, and I would like to create a web interface that can pass/pull data to an...

What is the Equivalent of "object of C# " in VC++?

In C# we have a datatype object which can hold any type of data. Same thing I want to achieve in VC++. Can anyone kindly let me know VC++ equivalent of "Object of C#". IN C#, in the calling appl program (say call.cs) object ob=null; ob=(object)str; funct(ref ob); Here str is empty string. This thing I want to achieve in VC++. ...

Drawing polygon with more than one hole?

I'm trying to draw a polygon with more than one holes. I tried the following code and it does not work correctly. Please advise. PointF[] mypoly = new PointF[6 + 5 + 5]; mypoly[0] = new PointF(0, 0); mypoly[1] = new PointF(100, 0); mypoly[2] = new PointF(100, 100); mypoly[3] = new PointF(0, 100); mypoly[4] = new...

Memory Management in Qt

HI all, I have small doubt about Qt memory management, Lets take an example of Listview, in listview we add each item by allocating memory dynamically. So in this case do we need to delete all the “new”ed items manually.. Eg: Qlistview *list = new Qlistview; QStandardItemModel *mModel = new QStandardItemModel(); list ->setModel(mMode...

EnumProcesses() vs CreateToolhelp32Snapshot()

I was wondering if there are any differences - mostly performance wise - between the two Win32 API functions EnumProcesses() and CreateToolhelp32Snapshot() for enumerating all active processes and loaded modules. Or if one is better than the other to use and why. ...

C++ code to indent XML line

Hi. I am looking for C++ code to indent an xml line. I don't want to link with a library. I have my stream in one line like this <root><a>value_a</a><b>value_b</b></root> and I want to print it in a multi-line way (with tabs). <root> <a>value_a</a> <b>value_b</b> </root> does it ring a bell to anybody? ...

Have different result at different versions of gcc

Compare two codes as follow: 1 #include <new> 2 #include <cstdio> 3 class CA 4 { 5 public: 6 int i, j, k; 7 }; 8 9 int main() 10 { 11 int aa[4] = { 1, 2, 3, 4 }; 12 CA *i = new(aa) CA(); 13 printf("%d %d %d %d\n", aa[0], aa[1], aa[2], aa[3]); 14 return 0; 15 } 1 #include <new> 2 #in...

Getting the correct mouse position in SFML with OpenGL

My problem is related to getting the correct mouse co-ordinates from SFML while using OpenGL. Basically I am making a polygon rotate on the Z axis to look at the current cursor position. You can also move the polygon around the screen with the WASD keys. If the polygon stays in the center of the screen everything works great, but my p...

Linkage of class names

$3.5 - "In addition, a member function, static data member, class or enumeration of class scope has external linkage if the name of the class has external linkage." Any inputs on what does it mean by 'if the name of the class has external linkage'? Is the hint on 'local classes' (which probably don't have any linkage) as co...

Base class's destructor called without destroying the base class!

#include<iostream> using namespace std; class A { public: int i; A() {cout<<"A()"<<endl;} ~A() {cout<<"~A()"<<endl;} }; class B:public A { public: int j; B(): j(10) { this->i=20; this->~A(); } }; int main() { B abc; cout<<"i="<<abc.i...

Use static_assert to check types passed to macro

I unfortunately have several macros left over from the original version of my library that employed some pretty crazy C. In particular, I have a series of macros that expect certain types to be passed to them. Is it possible to do something along the lines of: static_assert(decltype(retval) == bool); And how? Are there any clever alte...

How to print bold string in C++?

Hi, I got an old application which was written in a C++. I have 0 experience with it but I am suppose to make some changes in app. One of them is to change some text. Problem is that part of updated text needs to be bold, but i have no idea how to do that. I googled but with no much success. Only think I now is to go to new line with \n...

Problem using distance transform with new OpenCV C++ interface / How to ensure that Mat is a binary mask?

Hello everyone I'm porting my code to use the new OpenCV C++ interface. I like the possibility to strictly type everything, so derive all my images and matrices from the template class: Mat_<type> var; Now I have problems using the distanceTransform function. My code does something like this: Mat_<float> imgGray; Mat_<unsigned char>...

Is stack-only variable possible in C++?

Currently I want to make wrapper accessor class in multithreaded environment. The purpose of the class is simple - Grab a lock on its construction and release a lock on its destruction. Other than that, it's identical to a normal pointer. Moreover, I want to prevent it from being created on heap area to ensure that the lock will be relea...

Software package for calculation of intersections of polyhedra in C/C++

There are many good packages for calculating the intersection of polygons. I have found the GPC library useful. I would like to compute intersections of polyhedra (piecewise linear boundaries) in 3D. Are there any good libraries in C/C++ for this? ...

Searching for thread start parameters at top of stack

I've inherited some code that worked on Windows 2000 thats using a small piece of assembly code to locate the base address of the stack, then it uses an offset to grab the parameter value passed to the thread start function. However this doesnt work in Windows 2008 Server. The offset is obviously different. #define TEB_OFFSET 4 DWO...

Function definition and function type

Hi, I have the following code which works as expected: #include <iostream> using namespace std; typedef int (TMyFunc)(int); TMyFunc* p; int x(int y) { return y*2; } int main() { p = &x; cout << (*p)(5) << endl; } What I want to do is skip defining x and define p there straight. Something like TMyFunc p; p(y){retu...

How transport to dev team software crash'es from remote clients machines?

Hello, I searching people who know some experience with bug tracking on client machines, if my application works on many client machines who i don't have to it any access. I have in my application very huge debug logging feature, but in many cases this is to less to good detect problem of crash without very bigs and unreadable logs, the...

delete element in c++ array

Please tell me how to delete an element from a c++ array ? my teacher is setting its value to 0, is it correct ? ...

C++ Class instantiation problem

I have included the proper Header Files , Header Gard but i cannot instantiate a specific class Getting Error error C2065: 'ClassName' : undeclared identifier Sample Code Class A{ //instantiate class B } Class B { //need to instantiate Class A } ...