c++

Using detours for hooking writing text in notepad

Hi all. I'm trying to use detours to hook text output for example in notepad. I wrote the following code. I will not put here all code, but the most significant parts. DLL part: DLLEXPORT LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode < 0) { return CallNextHookEx(0, nCode, wParam, lParam); } if (n...

autoexp.dat not parsing union?

I have an in-place vector class that's defined like so: template<class T> class svectorbase { // ... protected: union { char* m_char; T* m_t; } m_elems; size_t m_maxsize; int m_elemCount; }; template<class T, size_t maxsize> class svector : public svectorbase<T> { protected: char m_elems[siz...

will be this initialization syntax valid in upcoming c++0x standard ?

Suppose we have following two classes: class Temp{ public: char a; char b; }; class Final{ private: int a; char b; char c; public: Final(Temp in):b(in.a),c(in.b){} //rest of implementation }; can we initialize an object of the Final class with following syntax in upcoming c++0x standard: Final obj(Temp{'a','b'}); ...

scoped_ptr for structure with substituted free method

I have a structure typedef struct myStruct_st { int a; }myStruct; It can be created using myStruct * myStruct_new() { printf("Allocate\n"); return new myStruct; } And deleted using static void myStruct_free(myStruct * ptr) { printf("Deallocate\n"); delete ptr; } I want the memory allocated for the structure freed au...

Question about the volatile keyword

I know that by the volatile keyword, volatile int k=7; we hint the compiler that the variable can be changed at any time but what about a simple int k=7? Can we change it at any time because it is not constant? What is different? ...

Standard Library Source File

I am using GCC on cygwin, but I want to browse for source file of string.cpp from the standard library . I just want to read the source file for knowledge of the function I am using, but the problem is I can't find it anywhere. I only find the header files but not the source files. I assume it is store somewhere else, or maybe in another...

using System::Drawing namespace in managed C++ class library

Hi Everyone, I am moving a few functions from a Managed C++ Winforms app to a class library so that I can call them in a new C# app I'm writing. However one of the functions returns a System::Drawing::Bitmap^ and uses the System::Drawing::Color class which is causing an error saying that System does not contain a namespace called Drawin...

Q_OBJECT linker error!!

Hi, I am receiving the following linker error when I build my application. HIMyClass.obj:: error: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CHIMyClass::metaObject(void)const " (?metaObject@CHIMyClass@@UBEPBUQMetaObject@@XZ) File not found : HIMyClass.obj HIMyClass.obj:: error...

C++ - Superclass constructor producing an instance of a subclass

Hi. I have two classes, one of which is a subclass of another, and differs only by the fact that it contains an additional member variable to its parent. I am not using the default constructor, passing in a reference to a single object as the constructors parameter. What I would like is for the constructor of the parent to examine this ...

Netbeans: how to include other c++ static library project?

I am really new to c++ and am using Netbeans for now. I managed to create a Sign.h and Sign.cpp containing a working class Sign. I added these to a Console Project and it works great: #include <iostream> #include <ostream> #include "Sign.h" int main() { Sign sign = Sign::parse("b"); std::cout << sign.toString() <...

Why do I need std::get_temporary_buffer ?

For what purpose I should use std::get_temporary_buffer? Standard says the following: Obtains a pointer to storage sufficient to store up to n adjacent T objects. I thought that the buffer will be allocated on the stack, but that is not true. According to the C++ Standard this buffer is actually not temporary. What advantages does ...

Lifetime of Qt Objects

What are the lifetimes of Qt Objects? Such as: QTcpSocket *socket=new QTcpSocket(); When socket will be destroyed? Should I use delete socket; Is there any difference with: QTcpSocket socket; I couldn't find deep infromation about this, any comment or link is welcomed. ...

WebBrowser Control in 32bit app Launches 64bit Internet Explorer on window.open() call

I have a 32bit application running on Windows 7 64bit. The application (written in C++) hosts a WebBrowser control. When the WebBrowser control is asked to popup a new windows (through a javascript window.open() call), it launches a new Internet Explorer process. In particular, this new IE process is a 64bit IE process. Since web pag...

How can class fields be initialized?

A bit of a basic question, but I'm having difficulty tracking down a definitive answer. Are initializer lists the only way to initialize class fields in C++, apart from assignment in methods? In case I'm using the wrong terminology, here's what I mean: class Test { public: Test(): MyField(47) { } // acceptable int MyField; };...

Arguments in a function prototype

Hi. My question is: when i write a function prototype in C like this: void foo(int *vector); It's the same thing to do: void foo(int vector[MAX_LENGTH]); To the function, is passed always as a pointer? The code it's the same? Thanks in advance. ...

C stat() and daylight savings

I'm having serious trouble with the function stat(). I have an application compiled under cygwin ond Windows 7 and the same app compiled with MSVC++ on Windows 7. The app contains the following code: struct stat stb; memset( &stb, 0, sizeof( stb ) ); stat( szPath, &stb ); cout << hex << uppercase << setw(8) << stb.st_mtime << endl; ...

Typedef Generalisation

Hi, I need to generalise a C++ typedef so I do not need to copy and paste a lot of code. I am serializing blitz arrays using boost and I am defining my own load and save methods and need to do this based on template parameters. Basically I don't know how to generalize typedef blitz::Array<double, 2> my_Matrix; for higher order te...

How to convert a void* to a type that can be used in C#? Interoperability between C DLL and C#

Hi, I am a C/C++ programmer, but I was asked to update a program that was written in C# to communicate with a device. My knowledge of C# is very basic. The previous version was totally written in C#, but now the API that in fact access the device was changed to C. I found out that I can import the C function APIs by using: [DllImport(...

How-to override KeyPressEvent for an editable QComboBox ?

Hi, I have a class named ValidableComboBox that derives directly from QComboBox. Every instance of ValidableComboBox has setEditable() set to true. My goal is to add some signal that will be emitted whenever someone presses return key in the QComboBox. To do so, I reimplemented void KeyPressEvent(QKeyEvent* e) in ValidableComboBox. Ho...

C++ Pointer data members: Who should delete them?

So say I have a class like this: class A { public: A( SomeHugeClass* huge_object) : m_huge_object(huge_object) {} private: SomeHugeClass* m_huge_object; }; If someone uses the constructor like this: A* foo = new A(new SomeHugeClass()); Who's responsibility is it to call delete on the obje...