c++

IPv6 address validation and canonicalization

What libs have you used for that? How compatible are they with one another? Or did you write your own parsing routine? I'm particularly interested in mutually-compatible implementations for Java, C++, Python, and JavaScript, which support: zero compression ("::") IPv4-mapped addresses ("::ffff:123.45.67.89") canonicalization (includ...

CGrigCtrl horizontal scrolling

How to enable horizontal scrollbar smooth scrolling for CGridCtrl. Now it jumps by fields when I scroll it from left to right. ...

Motif main window w/o system menu, minimize and maximize boxes how? (C++)

How do I create a Motif main window that doesn't have a system menu, minimize and maximize boxes? I just cannot find out how by googling and reading docs and tutorials. I believe that it should be possible with some additonal parameters for XtVaCreateManagedWindow, but which? Edit: I have tried several variants of XtVaSetValues (topWid...

Singletons via static instance in C++ -- into source or into header files?

Cheers, I ran into this chunk of code in "Programming Game AI by Example": /* ------------------ MyClass.h -------------------- */ #ifndef MY_SINGLETON #define MY_SINGLETON class MyClass { private: // member data int m_iNum; //constructor is private MyClass(){} //copy ctor and assignment should be private MyClass(const ...

std c++ container element destruction and insertion behaviour

I have made the following little Program: (basically a class that couts if it gets created, copied or destroyed and a main that does some of that) class Foo { public: Foo(string name): _name(name) { cout << "Instance " << _name << " of Foo created!" << std::endl; }; Foo(const Foo& other): _name(other._name) { cout << "Instance ...

Motif: Intercept close box event and prevent application exit? (C++)

How do I intercept when the user clicks on a motif window's (widget's) close box, and how do I prevent the Motif window manager to close the entire calling application on the close box being clicked (so that my app can close the Motif application context and windows and continue to run)? I've tried to find out myself with Google, tuts an...

cancelling std::cout code lines using preprocessor

One can remove all calls to printf() using #define printf. What if I have a lot of debug prints like std::cout << x << endl; ? How can I quickly switch off cout << statements in a single file using preprocessor? ...

Why is Qt looking for my slot in the base class instead of derived one?

I have my class X which inherits from Qt's class Base. I declared and defined void mySlot() slot in my class X and I'm connecting some signal to this slot in X's constructor. However, when running my program I get an error message saying there's no such slot as void mySlot() in the class Base. Why is the code generated by Meta Object Co...

How to debug macros efficiently in VS?

Hello, I've got a pretty complicated macro inside my (unmanaged) C++ code. Is there any way to expand macros in VS debugger? Or maybe there is another way to debug macros there? F.e. I'd like to place a breakpoint inside it. (Yes, I know macros are bad.) ...

C++ Copy Constructor Syntax

I apologize in advance, my C++ is rusty... What does : m_nSize(sizeof(t1)) mean in the following section? class CTypeSize { public: template<class T> CTypeSize(const T &t1) : m_nSize(sizeof(t1)) { } ~CTypeSize(void){ }; int getSize(void) const{ return m_nSize; } private: const in...

Variable-length objects: Ever a good idea?

My application uses a large amount of Panda objects. Each Panda has a list of Bamboo objects. This list does not change once the Panda is initialized (no Bamboo objects are added or removed). Currently, my class is implemented as follows: class Panda { int a; int b; int _bambooCount; Bamboo* _bamboo; Panda (int c...

How can I use std::remove on a container with std::tr1::weak_ptr?

If I had a STL container, say a list of pointers I could remove them like in the exmple below. With a container of weak_ptrs this does not work, because they cannot be compared, as they need to be locked first. What can I do? void MyClass::RemoveItem(std::tr1::weak_ptr<Item> const & pItem) { mylist.remove(pItem); } ...

Doing pointer math in a c++ class: Is it "legit"?

Ah-hoi, hoi, I'm wondering if it's ok to do something like the following: class SomeClass { int bar; }; SomeClass* foo = new SomeClass(); int offset = &(foo->bar) - foo; SomeClass* another = new SomeClass(); *(another+offset) = 3; // try to set bar to 3 Just Curious, Dan O ...

How to write a MultiPart download C++ program

I want to write a C++ program to download files with HTTP. For the sake of learning I would like to implement multipart downloading in my program the way DownThemAll! does. It is not possible to do lseek on a linux socket. I suppose it would be some HTTP option that we would need to specify, telling where to start downloading the file fr...

HTTP parsing library for linux C++

can anyone suggest a good HTTP parsing library for linux? ...

C++ static operator overloading

Is it possible to overload C++ class operators in the static context? e.g. class Class_1{ ... } int main() { Class_1[val]... } ...

Enumerate over an enum in C++

In C++, Is it possible to enumerate over an enum (either runtime or compile time (preferred)) and call functions/generate code for each iteration? Sample use case: enum abc { start a, b, c, end } for each (__enum__member__ in abc) { function_call(__enum__member__); } Plausible duplicates: C...

c++ developers which java framework do you like to see in c++

as c++ developer and java developer i always was fascinating from the solutions that java have to offer to any problem as framework that you just drop to your class path and walla.. you can work with it . what are the frameworks do you wish was ported from java to c++ ? ...

Are static variables in a base class shared by all derived classes?

If I have something like class Base { static int staticVar; } class DerivedA : public Base {} class DerivedB : public Base {} Will both DerivedA and DerivedB share the same staticVar or will they each get their own? If I wanted them to each have their own, what would you recommend I do? ...

Simulating static constructors in C++?

Is there anyway I can modify this code example #include <stdlib.h> #include <iostream> class Base { public: Base() { if(!m_initialized) { static_constructor(); m_initialized = true; } } protected: virtual void static_constructor() { std::cout << "Base::static_constructor()\n";...