c++

Using an ocx in a console application

I want to quickly test an ocx. How do I drop that ocx in a console application. I have found some tutorials in CodeProject and but are incomplete. ...

Importing C++ enumerations into C#

I'm currently working on creating a new C# project that needs to interact with an older C++ application. There is an error enumeration that already exists in the C++ app that I need to use in the C# app. I don't want to just redeclare the enumeration in C# because that could cause sync issues down the line if the files aren't updated to...

How to install a plugin for QtWebKit

I am running a Qt 4.5 commercial snapshot and want to use a plugin that i downloaded (it's a .so file) in my QWebView. Is there a specific location where I need to place this file? Can I grab it using the QWebPluginFactory? ...

How to match linux device path to windows drive name?

Hi, I'm writing an application that on some stage performs low-level disk operations in Linux environment. The app actually consists of 2 parts, one runs on Windows and interacts with a user and another is a linux part that runs from a LiveCD. User makes a choice of Windows drive letters and then a linux part performs actions with corre...

How to make a tree in C++?

How do I make a tree data structure in C++ that uses iterators instead of pointers? I couldn't find anything in the STL that can do this. What I would like to do is to be able to create and manipulate trees like this: #include <iostream> #include <tree> using namespace std; int main() { tree<int> myTree; tree<int>::iterator ...

What is the best way to go from Java/C# to C++?

At my university most of my classes have been in Java. I have also recently learned C# (and the Visual Studio environment) at a summer internship. Now I'm taking an Intro to Computer Graphics class and the grad student teaching the class prefers us to use C++ to access the OpenGL bindings via GLUT. Does anyone have any good resources ...

In C++, how do you clear a stringstream variable?

I've tried several things already, std::stringstream m; m.empty(); m.clear(); both of which don't work. ...

When to use STL bitsets instead of separate variables?

In what situation would it be more appropriate for me to use a bitset (STL container) to manage a set of flags rather than having them declared as a number of separate (bool) variables? Will I get a significant performance gain if I used a bitset for 50 flags rather than using 50 separate bool variables? ...

In C++ can constructor and destructor be inline functions?

VC++ makes functions which are implemented within the class declaration inline functions. If I declare a class Foo as follows, then are the CONSTRUCTOR and DESTRUCTOR inline functions? class Foo { int* p; public: Foo() { p = new char[0x00100000]; } ~Foo() { delete [] p; } }; { Foo f; (f); } ...

In C++ virtual base class?

I think you might dislike C++ crappy features but I just want to know what is virtual base class and what it means: Let me show an example: class Foo { public: void DoSomething() { /* ... */ } }; class Bar : public virtual Foo { public: void DoSpecific() { /* ... */ } }; Please teach me! ...

what is the difference between #include <filename> and #include "filename"

In the C and C++ programming languages, what is the difference between using angle brackets and using quotes in an include statement. #include <filename> #include "filename" ...

C++: Reading from text file until EOF repeats last line

The following C++ code uses a ifstream object to read integers from a text file (which has one number per line) until it hits EOF. Why does it read the integer on the last line twice? How to fix this? Code: #include <iostream> #include <fstream> using namespace std; int main() { ifstream iFile("input.txt"); // input.txt has intege...

Why does int main() {} compile?

(I'm using Visual C++ 2008) I've always heard that main() is required to return an integer, but here I didn't put in return 0; and and it compiled with 0 errors and 0 warnings! In the debug window it says the program has exited with code 0. If this function is named anything other than main(), the compiler complains saying 'blah' must ...

Implementing a log watcher

I wondering how in C/C++ you can implement a program (similar to tail -f) that watches for new lines added to a log file and then process them? ...

memset() causing data abort

I'm getting some strange, intermittent, data aborts (< 5% of the time) in some of my code, when calling memset. The problem is that is usually doesn't happen unless the code is running for a couple days, so it's hard to catch it in the act. I'm using the following code: char *msg = (char*)malloc(sizeof(char)*2048); char *temp = (char*...

What is the best way to communicate with a SQL server?

I am going to be using c/c++, and would like to know the best way to talk to a MySQL server. Should I use the library that comes with the server installation? Are they any good libraries I should consider other than the official one? ...

How Does One Sum Dimensions of an Array Specified at Run-Time?

Hi all, I am working on a function to establish the entropy of a distribution. It uses a copula, if any are familiar with that. I need to sum up the values in the array based on which dimensions are "cared about." Example: Consider the following example... Dimension 0 (across) _ _ _ _ _ _ _ _ _ _ _ _ _ |_ 0 _|_ 0 _|_ 0 _|_ 2 _| D...

Find out which process has an exclusive lock on a USB device handle

I have a library that reads/writes to a USB-device using CreateFile() API. The device happens to implement the HID-device profile, such that it's compatible with Microsoft's HID class driver. Some other application installed on the system is opening the device in read/write mode with no share mode. Which prevents my library (and anythin...

C++ linker unresolved external symbols

I'm building an application against some legacy, third party libraries, and having problems with the linking stage. I'm trying to compile with Visual Studio 9. My compile command is: cl -DNT40 -DPOMDLL -DCRTAPI1=cdecl -DCRTAPI2=cdecl -DWIN32 -DWIN32 -DWIN32LEANANDMEAN -DWNT -DBYPASSFLEX -D_INTEL=1 -DIPLIB=none -I. -I"D:\src\inclu...

When do you use the "this" keyword?

This may be a silly question, but I was curious how other people use the this keyword. I tend to use it in constructors but may also use it throughout the class in other methods. Some examples: In Constructor: public Light(Vector v) { this.dir = new Vector(v); } Elsewhere public void SomeMethod() { Vector vec = new Vector(...