c++

Is Int32^ i = gcnew Int32() allocated on managed heap?

Basically I would like to know the difference between Int32^ i = gcnew Int32(); and Int32* i2 = new Int32(); I have written the following code: #include <stdio.h> #using <mscorlib.dll> using namespace System; int main(void) { Int32^ i = gcnew Int32(); Int32* i2 = new Int32(); printf("%p %d\n", i2, *i2); pr...

Runtime optimization of static languages: JIT for C++?

Is anyone using JIT tricks to improve the runtime performance of statically compiled languages such as C++? It seems like hotspot analysis and branch prediction based on observations made during runtime could improve the performance of any code, but maybe there's some fundamental strategic reason why making such observations and impleme...

pointer in recurrence Fun

Hello to every body I hope every one keep in best state. I want to help me in solve this problem in my Sheet . I use recurrence functions in like list.( with ADT file ) by modify the search function and adding Printing function in a Reverse Manner. template <class TYPE, class KTYPE> bool List<TYPE, KTYPE> :: _search (NODE<TYPE> **pP...

Object files generation and best practices for linking using makefiles - C++

Background I am just getting started with C++ programming on LINUX. In my last question, I asked about best practices of using makefiles for a big application. "SO" users suggested to read Miller's paper on recursive makefiles and avoid makefile recursion (I was using recursive makefiles). I have followed miller and created a makefile...

Debugging embedded Lua

How do you debug lua code embedded in a c++ application? From what I gather, either I need to buy a special IDE and link in their special lua runtime (ugh). Or I need to build a debug console in to the game engine, using the lua debug API calls. I am leaning toward writing my own debug console, but it seems like a lot of work. Time th...

Why this sample works?

> typedef pair<double, double> dd; const double epsilon = 1e-6; struct sort_by_polar_angle { dd center; // Constuctor of any type // Just find and store the center template<typename T> sort_by_polar_angle(T b, T e) { int count = 0; center = dd(0,0); while(b != e) { ...

Populate a static member container in c++

I've got a static class member which is some container, like (Foo.h) class Foo { ... private: static list<string> s_List; } I need to populate the list with a number of specific values. Actually it should be also const, but that might overcomplicate the problem further. All the class member functions are static, so initializing...

What is a good Linux IDE for code completion?

So far for C++ Linux development, I've used Eclipse CDT and Code::Blocks. Compared to Visual Studio on Windows, their code completion features aren't too great. Could someone please suggest an IDE that has better C++ code completion than what I have tried so far? A thread on the Ubuntu Forums suggests that Code::Blocks is actually super...

What is the typical usage of boost any library ?

Hello! What are the advantages of using boost.any library ? Could you please give me some real life examples ? Why the same functionality couldn't be achieved by having some generic type in the root of object's hierarchy and creating containers with that base type ? ...

Wrapping a 3rd party DLL

Hi, I have a 3rd party DLL that needs to be loaded dynamically using LoadLibrary() and which uses the __cdecl calling convention. I need to be able to use the dll from VB6 so I've created a wrapper DLL of my own that uses the __stdcall calling convention and exports the functions that are needed. An additional requirement has now arri...

Implementing zoom controls in MFC

I am working on a 'print preview' facility to show an overview of a slide with rectangular arrays of sample spots on it. The slides typically measure 25 x 75 mm and the spot samples are typically 0.1 mm in diameter. There is usually a 2mm gap around the perimeter of the slide where no spots are printed. The distance between spots (pit...

How do a specify a library file dependency for qmake in Qt?

Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET = SomeLib .. Then in a dependent SomeApp.pro: .. debug:LIBS += -lSomeLib_debug .. How can I force SomeApp to build if I touched SomeLib in qmake? ...

Weird linker error on Borland C++ Builder 6

I've been trying to compile a Borland C++ Builder 6 project, but linker dies with exact following error: [Linker Fatal Error] Fatal: Unable to open file '.OBJ' Strange thing about it is that it doesn't give any file name except the extension. It looks like an internal bug, though googling for it didn't give any results. Has anyone enc...

How to define a Copy constructor with pointers in it?

I have recently discovered that when I have pointers within a class, I need to specify a Copy constructor. To learn that, I have made the following simple code. It compiles, but gives me runtime error when performing the copy constructor. I am trying to copy just the value from the pointer of the copied object, but avoiding assigning t...

How do I debug a single .cpp file in Visual Studio?

Is there any way to debug a single file in Visual Studio.NET? I'm still a noob with C++, but I want to start learning how to get comfortable with the debugger, and as of right now I am writing really small files. It seems if there is only one source file, it won't let me debug, but the moment I add another one, I can. I am using VS.net...

Generating object file to separate directory using g++ compiler - C++

I use the following code to compile a cpp file to object file. g++ -c main.cpp Above code generates the .o fles in same directory where main.cpp resides. Suppose I have a folder named obj and need to generate the object files there, how do I write? How can I see the compiler switches supported by g++ and it's usages? Any help wou...

C++ HTML generation classes

A question prompted by jbar's question. In scripting languages like Python, Ruby, and Perl, there are libraries that simplify generating dynamic HTML. (For example, the cgi module in Ruby.) Are there any similar packages for C++? I don't know of one, and at least some desultory googling didn't reveal one. ...

Problem implementing Marching Cube Algorithm.

From My last question: Marching Cube Question AndreasT has explained to me how the triTable and edgeTable works. I really can't thank him enough. However, i am still unclear as in: how to create imaginary cube/voxel to check if a vertex is below the isosurface? how do i know which vertex is below the isosurface? how does each cube/vo...

parse dynamic function form string

I'm beginner in c++ and I hopeless to parse dynamic function form string like char* func = "app.exe /path:\"@FileExists('filepath', @FileDelete('filepath'), @MsgBox('file not found','error',1))\"; I want to parse @FileExists('filepath', @FileDelete('filepath'), @MsgBox('file not found','error',1)) can you help me? sorry for my en...

Draw array of bits(rgb) in windows

I have an array of raw rgb data. I would like to know how can I draw this pixels on the screen in Windows OS? Now I use API function DrawDIBits, but I must turn up my image data. ...