c++

How to make use of c++ xpcom component from javascript xpcom component.

I have developed a xpcom component using c++. I have GetHWND() method in my component. I have also developed another xpcom component using javascript. I want to make use of GetHWND function in javascript xpcom component. I am using following code to do so. netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); ...

Returning reference to class with overloaded private & operator?

I got a class called Property (from external library == cannot be modified) that has private overloaded & operator. I use this class in another class as a property and (for sanity reasons) I'd like to return a reference to this property through the Get method. However I got the 'cannot access private member declared in class' error I can...

Can't recursive functions be inlined?

Possible Duplicate: Can a recursive function be inline? What are the trade offs of making recursive functions inline. ...

Pass a variable number of arguments to an aliased function.

Take a function like printf that accepts a variable number of arguments what I would like to do is pass these variable number of functions to a sub function without changing their order. An example of this would be aliasing the printf function to a function called console ... #include <stdio.h> void console(const char *_sFormat, ...);...

Should i override operators new/delete in my c++ WIn32 applications

Hi, I know Microsoft themselves used to recommend overriding operator new with calls to HeapCreate() and HeapAlloc(), but that was a while ago. See KB139638 for more details. Would i still benefit from overriding new/delete on Win32? What would be the recommended implementation? TIA. ...

Should I use "this" to call class properties, members, or methods?

I've seen some guides or blogs that say using this to access a class's own members is bad. However, I've also seen some places where professionals are accessing with this. I tend to prefer explicitly using this, since it seems to make it clear that the thing I'm accessing is part of the class. this.MyProperty = this.GetSomeValue(); Is...

how to read a list of current running process in linux using C++

i need to read the list of current running process into a C++ program. I know that one way to do is to use ps command and other is to read /proc file system but i want to know how one can get names of processes by reading /proc file system. also is there any other way to read the list. ...

Modular Exponentiation for high numbers in C++

Hello all! So I've been working recently on an implementation of the Miller-Rabin primality test. I am limiting it to a scope of all 32-bit numbers, because this is a just-for-fun project that I am doing to familiarize myself with c++, and I don't want to have to work with anything 64-bits for awhile. An added bonus is that the algori...

Reference to element in 2d vector (c++)

Hi, I have a class named Spring in a particle system. The constructor looks like: Spring(Particle& _a, Particle& _b); And I have a vector of Particles and I use Spring mySpring = Spring(myParticles.at(j),myParticles.at(j+1)); inside a loop to add a spring force between two particles. Everything works fine so far. However, I want t...

What are app domains used for?

I understand roughly what an AppDomain is, however I don't fully understand the uses for an AppDomain. I'm involved in a large server based C# / C++ application and I'm wondering how using AppDomains could improve stability / security / performance. In particular: I understand that a fault or fatal exception in one domain does not a...

Range for FD (File Descriptor) in Linux

Possible Duplicate: Is 0 or 1 valid return values for socket() function call what is the range for FD(File Descriptor)? For example : int sockfd = socket(AF_INET, SOCK_STREAM, 0); or newsockfd = accept(sockfd, (struct sockaddr *) & cli_addr, (socklen_t *) & clilen); what is the range sockfd , newsockfd ? Are these >...

Alternative to Factory Pattern when creating templated objects - C++

Hi, I want to implement a Mesh class for a CG project, but have run into some problems. What I want to do is a Mesh class that hides implementation details (like loading to a specific API: OpenGL, DirectX, CUDA, ...) from the user. Additionally, since the Mesh class will be used in research projects, this Mesh class has to be very flexi...

How do I define friends in global namespace within another C++ namespace?

Hi, I'd like to define a binary operator on in the global namespace. The operator works on a class that is defined in another namespace and the operator should get access to the private members of that class. The problem I have is that I don't know how to scope that global operator when making it a friend in the class definition. I tri...

Odd optimization problem under MSVC

I've seen this blog: http://igoro.com/archive/gallery-of-processor-cache-effects/ The "weirdness" in part 7 is what caught my interest. My first thought was "Thats just C# being weird". Its not I wrote the following C++ code. volatile int* p = (volatile int*)_aligned_malloc( sizeof( int ) * 8, 64 ); memset( (void*)p, 0, sizeof( int ...

Can I forbid calling static methods on object instance?

I have class with lots of conversion functions: class Something { public: string toXml(); string toJson(); ... static Something fromXml(string); // factory static Something fromJson(string); // factory ... }; Because static functions can be called on instance, it is easy to write code like this: Something...

Qt Translation lupdate and namespaces

Hello While developing a Qt Application, I ran into a problem in using QTranslator. After a little research, I found out that the problem was with lupdate from Qt having problem with the using namespace; directive. Following the instructions found in here, I discovered that I have to use special comments in my code, to help lupdate u...

Why paint messages get lost even after calling UpdateWindow() ?

I have an application with following windows hierarchy: W1 -W2 (Child of W1) - W3 ( Child of W2) --------------------| | W1|------------| | | |W2 |------| | | | | |W3 | | | | | |------| | | | |------------| | |-------------------| When certain event happens in W2, I call UpdateWindow: W2::onCertainEvent()...

Changing a label in Qt

I'm trying to make a simple program consisting of a button and a label. When the button is pressed, it should change the label text to whatever is in a QString variable inside the program. Here's my code so far: This is my widget.h file: class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(...

Calling in C++ a non member function inside a class with a method with the same

Hello all, I have this class with an instance method named open and need to call a function declared in C also called open. Follows a sample: void SerialPort::open() { if(_open) return; fd = open (_portName.c_str(), O_RDWR | O_NOCTTY ); _open = true; } When I try to compile it (using GCC) I get the following erro...

QtWebkit synchronous loading

Hi, I'm using a QWebPage without a QWebView because I want to render the contents of an HTML file onto a QPixmap/QImage. I want the loading of the page to be done synchronously, not asynchronously which is the default. The default way is to call QWebFrame::setHtml() or QWebFrame::setContent(), but this loads images asynchronously. Wha...