c++

Call virtual method from base class on object of derived type

class Base { public: virtual void foo() const { std::cout << "Base"; } }; class Derived : public Base { public: virtual void foo() const { std::cout << "Derived"; } }; Derived d; // call Base::foo on this object Tried casting and function pointers but I couldn't do it. Is it possible to defeat ...

using win32 api in linux ?

I have heard of WINE but I don't like it because it's slow on the computers I have tested and almost always crashes. It also has some unpleasant looking gui. I am wondering if there is a "win32" library in c/c++ for linux that produces native linux code so that if I have my source code for windows, I can just recompile and produce a work...

Should I Put Critical Section While Getting Connection from OCCI Environment

Hello, I'm writing a multi-threaded application. My worker threads get connection from an environment object as follows:. //EnterCriticalSection(&cs); conn = env->createConnection(username, password, connStr); //LeaveCriticalSection(&cs); For concurrency, should the connection be created in a critical section or not? Does the env nee...

POST request with QWebView

How can I issue a POST request over a QWebView instance? ...

Count Similar iTems in Array

Hi guys, I need to count the similar elements in an array. For example, if i have an array, array[0,0,0,1,2,3,3].The number of 0's are 3 , no. of 1's are 1 , no. of 2's are 1 , no. of 3's are 2 in this array . I am sorry if this message has been posted before. Help is appreciated. Thanks in advance. Regards, THM P.S : Language is C/C...

Problems with first argument being string when overloading the + operator in C++

I have an selfmade Stringclass: //String.h String & operator = (const String &); String & operator = (char*); const String operator+ (String& s); const String operator+ (char* sA); . . //in main: String s1("hi"); String s2("hello"); str2 = str1 + "ok";//this is ok to do str2 = "ok" + str1;//but not this way //Shouldn't it automatica...

When is #include <new> library required in C++?

Hi, According to this reference entry for operator new ( http://www.cplusplus.com/reference/std/new/operator%20new/ ) : Global dynamic storage operator functions are special in the standard library: All three versions of operator new are declared in the global namespace, not in the std namespace. The first and second...

Calling activateWindow on QDialog sends window to background

I am debugging certain application written with C++/Qt4. On Linux it has problems that with certain window managers (gnome-wm/metacity), the main window (based on QDialog) is created in the background (it's not raised). I managed to re-create the scenario using PyQt4 and following code: from PyQt4.QtCore import * from PyQt4.QtGui import...

How to make WebBrowser control with transparent background?

Hi all. I try to make my WebBrowser control transparent, so if the HTML loaded into it has no background, the underlying window should be visible. I`ve broke my head trying different ways. There is a transparent background in Microsoft Sidebar application. In gadget`s HTML <g:background> tag can be used, but this tag is not available i...

std::make_shared as a default argument does not compile

In Visual C++ (2008 and 2010), the following code does not compile with the following error: #include <memory> void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) ) { } class P { void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) ) { } }; error C2039: 'make_shared' : is not a...

algorithms that destruct and copy_construct

I am currently building my own toy vector for fun, and I was wondering if there is something like the following in the current or next standard or in Boost? template<class T> void destruct(T* begin, T* end) { while (begin != end) { begin -> ~T(); ++begin; } } template<class T> T* copy_construct(T* begin, T* ...

Drawing and loading a GL_DEPTH_COMPONENT texture

I'm trying to load a depthbuffer from a file and copy it to the depth buffer instead of clearing it every frame. anyway, i'm a bit new to opengl, so i just tried to load my texture like this: glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, DepthData); and i try to draw it lik...

How to get information about a Windows executable (.exe) using C++

Hi, I have to create a software that will scan several directories and extracts information about the executables found. I need to do two things: Determine if a given file is an executable (.exe, .dll, and so on) - Checking the extension is probably not good enough. Get the information about this executable (the company name, the pro...

C++ snippet support in visual studio?

I'm writing code in native C++ (not C++/CLR). I know that there is no built-in support for C++ with regards to the snippet manager and snipper picker interfaces, however I found a utility called "snippy" which supposedly can generate C++ snippets. Here is a c++ snippet that the program generated: <?xml version="1.0" encoding="utf-8"?> <...

.NET consumer of ActiveX throwing TargetParameterCountException

I have a .NET (3.5 w/ Dev Studio 2008) app that hosts a visual Active X (written in C++ w/ Dev Studio 2003). Have access to all sources, but can't easily move the Active X control up to 2008. This as worked fine in the past. Made some changes to the Active X control and now, when calling one method on the Active X, I'm getting a TargetP...

good/full Boot Spirit examples using version 2 syntax

Almost all of the examples I've gone and looked at so far from: http://boost-spirit.com/repository/applications/show_contents.php use the old syntax. I've read and re-read the actual documentation at http://www.boost.org/doc/libs/1_42_0/libs/spirit/doc/html/index.html and the examples therein. I know Joel is starting a compiler series ...

How to determine at runtime when your C++ application has the visual studio debugger attached?

How do you determine at runtime whether the visual studio debugger is attached to your process. I've seen instructions for how to do this in .NET, but my process is a native C++ process. Support for detecting Just-in-time debugging would be nice but not a strict requirement. ...

Problem calling std::max

I compiled my bison-generated files in Visual Studio and got these errors: ...\position.hh(83): error C2589: '(' : illegal token on right side of '::' ...\position.hh(83): error C2059: syntax error : '::' ...\position.hh(83): error C2589: '(' : illegal token on right side of '::' ...\position.hh(83): error C2059: syntax error :...

Principal Component Analysis in a cluster via MPI

Hi All I am setting up a set of computers where to run math programs on top of MPI. Do you know whether exist some library doing PCA - Principal Component Analysis using MPI so to use all the resources of the networked pcs? I will have a look at Scalapack, but do you know other libraries? My language is C++ on linux but if there is a go...

Texture mapping an NGon?

I'm not sure how to go about figuring out how to map texture cooridnates for a 2D NGon (N sided polygon) How can this be done? The effect i'm trying to achieve is for the texture to fit on the polygon and stretch out accordingly so the whole texture fits on it. Thanks ...