c++

Is there equivalent of <? extends T> <? super T> in c++?

Is there equivalent of <? extends T> <? super T> in c++? Also, does <? extends T> <? super T> work even if T is an interface in Java? ...

C++ GNU Linker Errors

I'm trying to complie my program on Windows via Cygwin with the compilation command: g++ ping.cpp -I./include -L./lib -lchartdir50 I'm using an API called ChartDirector which draws charts for me. I've never linked libraries this way before (usually I do it through Visual Studio) so i'm a little new to this. I've got a really large lis...

How to structure files / dependencies in Visual C++ project

This is more of a design question than a C++ question. I'm working on a Texas Hold'Em poker game in C++. So far, I have a HandChecker module written that is responsible for determining a player's best hand given his hole cards and the community cards. I decided to move this out into a separate HandChecker project. HandChecker depends on...

Is it possible to have a while loop in c++ that makes the check in the middle of the loop instead of the beginning or end?

I want to have a while loop do something like the following, but is this possible in c++? If so, how does the syntax go? do { //some code while( expression to be evaluated ); // some more code } I would want the loop to be exited as soon as the while statement decides the expression is no longer true( i.e. if expression i...

Building optimized Qt4 - "./configure" flags and their meanings

Hey everyone, I recently followed a discussion on the Qt4-interest mailing list about whether it is legal or not to build a commercial/proprietary application and statically link Qt4 into it. While there are some non-proven ways of doing so (by providing object files and a Makefile, etc. to the customer), it doesn't sound like such a go...

Converting Delphi code for unmanaged dll to C#

Hi. I hope someone can assist me with the problem I'm currently experiencing. We have a lot of Delphi legacy code, and need to convert some of our Delphi applications to C#. The legacy code I'm currently struggling with is that of calling a function from a 3rd party application's non-COM DLL. Here is the C-style header and struct use...

Question about what I should have before Connect

I have this included: #include <sys/socket.h> /* for socket(), connect(), send(), and recv() */ /* Establish the connection to the echo server */ if (connect(sock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0) DieWithError("connect() failed"); But I am getting this: TCPClient.cpp:395: error: no matching func...

Conditionally instantiate a template at run-time.

I have a template class template <class T> class myClass { public: /* functions */ private: typename T::Indices myIndices; }; Now in my main code I want to instantiate the template class depending on a condition. Like : myFunc( int operation) { switch (operation) { case 0: // Ins...

Conditional operator issue

I'm having some trouble with using the conditional operator to get a reference to an object. I have the a setup similar to this: class D { virtual void bla() = 0; }; class D1 : public D { void bla() {}; }; class D2 : public D { void bla() {}; }; class C { public: C() { this->d1 = new D1(); this->d2...

Instantiation of function object with different inline function definitions depends on order of linkage

Hi all, Please help me understand the root cause of the following behaviour. In file a.cpp I have: namespace NS { struct Obj { void pong(){ cout << "X in "__FILE__ << endl; } double k; }; X::X() { Obj obj; obj.pong(); } void X::operator()() { cout << "X says hello" << endl; } } In file b.cpp I have: namesp...

Difference between using character pointers and character arrays

Basic question. char new_str[]=""; char * newstr; If I have to concatenate some data into it or use string functions like strcat/substr/strcpy, what's the difference between the two? I understand I have to allocate memory to the char * approach (Line #2). I'm not really sure how though. And const char * and string literals are the ...

C/C++ Macro expansion vs. Code generation

Both Macro expansion & Code generation have pros & cons. What's your favorite approach and why? When should we choose one over the other? Please kindly advise. Thank you! Macro expansion can be very handy & helpful: http://dtemplatelib.sourceforge.net/table.htm vs While Code generation gives you plenty of nice code: http://code.google...

How to write a const_iterator in VC++6?

I have implemented my own container class and need to implement a const_iterator for it. What is the easiest way to go about implementing const_iterator begin() const_iterator end() and const_iterator::operator++ for my own container class? Please provide examples. Thanks! ...

How to set up a trial for a dynamic link library?

Hello, I'm developing a shareware sdk-like library (using C++). The library is a simple dll provides some functions. So, my first question is what types of trials are possible for simple dll? I don't want to cut the functionality of the trial dll, so I tend to use time-trial. I roughly understand how to track usage time of the lib, so...

constructor as default argument

let's say i have 2 classes class B { B() { /* BLA BLA */ }; B(int a) { /* BLA BLA */ }; B(int a,int b) { /* BLA BLA */ }; } class A { public : A(B par); } i was wondering how can i call A's constructor with par having a deafult argument, as each of B constructors. (of course i would like see 3 examples, i don't expect all...

Quick Question on QT and OpenGl

I've made a project with QT and OpenGl. In QT paintGl() was repeatedly call I beleive, so I was able to change values outside of that function and call update() so that it would paint a new image. I also believe that it called initializeGl() as soon as you start up the program. Now my question is: I want that same functionality in a d...

wxImage to Zip file via stream. Possible?

I'm trying to write out a zip file using the wxZipOutputStream. The code is from this forum and works with the xml file (when I used wxTextOutputStream). Now, I'm trying to include an image file but the SaveFile function in the wxImage class expects a class wxOutputStream but wxTextOutputStream/wxDataOutputStream have no base class so I ...

Dividing by arbitrary numbers using shifting operators

How can you divide a number n for example by 24 using shifting operators and additions? (n % 24 == 0) ...

strcat query (string.h)

First off : STRCAT : Cplusplus - strcat When clearly the definition says : char * strcat ( char * destination, const char * source ); Why'd they use char str[80] in the example??? Shouldn't they have used a character pointer? ...

Question about how to send images in socket programming?

I've got a couple questions about sending images over. How do I handle different types of files, jpeg, png, etc. If the file is large, I ave to use sequence numbers... but I don't know how to stop recving if I do not know the number of sequence numbers. My knowledge of transfering images / files is next to none. I have never programme...