c++

Importing .dll into Qt

I want to bring a .dll dependency into my Qt project. So I added this to my .pro file: win32 { LIBS += C:\lib\dependency.lib LIBS += C:\lib\dependency.dll } And then (I don't know if this is the right syntax or not) #include <windows.h> Q_DECL_IMPORT int WINAPI DoSomething(); btw the .dll looks something like this: #include <win...

Can I use boost::make_shared with a private constructor?

Consider the following: class DirectoryIterator; namespace detail { class FileDataProxy; class DirectoryIteratorImpl { friend class DirectoryIterator; friend class FileDataProxy; WIN32_FIND_DATAW currentData; HANDLE hFind; std::wstring root; DirectoryIteratorImpl(); ...

Function pointer demo

Hi, Check the below code int add(int a, int b) { return a + b; } void functionptrdemo() { typedef int *(funcPtr) (int,int); funcPtr ptr; ptr = add; //IS THIS CORRECT? int p = (*ptr)(2,3); cout<<"Addition value is "<<p<<endl; } In the place where I try to assign a function to function ptr with same function si...

Function overloading

I found this code , and i m not sure that whether overloading should happen or not. void print( int (*arr)[6], int size ); void print( int (*arr)[5], int size ); what happens if I pass pointer to an array of 4 elements , to it should come... any thread will be helpful. ...

Customize page number when printing a QTextDocument

Hi, I'm trying to print the content of a QTextEdit. For that I'm using QTextDocument::print(QPrinter*). Doing that, a page number is automatically added at the right bottom of the page. Is there any way to change its format / move it / get rid of it? Thanks. ...

How do I combine hash values in C++0x?

C++0x adds hash<...>(...). I could not find a hash_combine function though, as presented in boost. What is the cleanest way to implement something like this? Perhaps, using C++0x xor_combine? ...

How to enable BDS2006's C++ WARN & TRACE macros.

I am trying to find out how to enable (& use) Borland's WARN & TRACE macros. My starting point was this link: http://bcbjournal.org/articles/vol2/9809/Debugging_with_diagnostic_macros.htm?PHPSESSID=37bf58851bfeb5c199d1af31d7b2e7ff However, that appears to be for BCB5, and not the 2006 Borland Developer Studio. I've set the two define...

C++0x without sequence point?

What does it mean by Sequence Point is deprecated from C++0x, Wikipedia says it is deprecated from C++0x. Does that mean undefined behaviors due to sequence point have no effect? ...

Is there a way to use template specialization to separate new from new[]?

I have an auto pointer class and in the constructor I am passing in a pointer. I want to be able to separate new from new[] in the constructor so that I can properly call delete or delete[] in the destructor. Can this be done through template specialization? I don't want to have to pass in a boolean in the constructor. template <typ...

Getting started with C++ ( the paradigm shift from Python )

I want to learn C++ so that i can develop C++ Python modules for server-related stuff. I'm a purely dynamic languages developer (Python, PHP, Ruby, etc). I want to learn a fast language, and if I'm going to do this, I'd rather learn a really fast language like C++. Before I even get started though, I understand that suddenly working wit...

C++ code to class diagram

Is there is a way I can generate a hierachial class diagram from C++ code. My code is spread over 5 to 6 .cpp files. I would like to know if there is any free tool for the same. Regards, AJ ...

Expected output from an RM-1501 RS232 interface?

I have an old RM-1501 digital tachometer which I'm using to try to identify the speed of an object. According to the manual I should be able to read the data over a serial link. Unfortunately, I don't appear to be able to get any sensible output from the device (never gives a valid speed). I think it might be a signalling problem becau...

VC6 compilation error

Hi there are some vs2005 c++ files in PJNSMTPCONNECTION Classes, but my application is in vc6, now can any one tell whether CSTRINGA, CSTRINGW are available in vc6.. if not how overcome this problem ...

Who calls the Destructor of the class when operator delete is used in multiple inheritance.

This question may sound too silly, however , I don't find concrete answer any where else. With little knowledge on how late binding works and virtual keyword used in inheritance. As in the code sample, when in case of inheritance where a base class pointer pointing to a derived class object created on heap and delete operator is used...

What is the point of function pointers?

Hi, I have trouble seing the utility of the function pointers. I guess it may be useful in some cases (they exist, after all), but I can't think of a case where it's better or unavoidable to use a function pointer. Could you give some example of good use of function pointers (in C or C++)? Many thanks :) ...

Testing C++ program with Testing classes over normally used classes

Hi Guys, This will probably be a bot of a waffly question but ill try my best. I have a simple c++ program that i need to build testing for. I have 2 Classes i use besides the one i actually am using, these are called WebServer and BusinessLogicLayer. To test my own code i have made my own versions of these classes that feed dummy da...

Does an abstact classes have a VTABLE?

Do we have virtual table for an abstract class? ...

Why is calling close() after fopen() not closing?

I ran across the following code in one of our in-house dlls and I am trying to understand the behavior it was showing: long GetFD(long* fd, const char* fileName, const char* mode) { string fileMode; if (strlen(mode) == 0 || tolower(mode[0]) == 'w' || tolower(mode[0]) == 'o') fileMode = string("w"); else if (tolowe...

About inconsistent dll linkage

How can I remove this link warning? You can see code segment that causes this warning. Also Thanks in advance. static AFX_EXTENSION_MODULE GuiCtrlsDLL = { NULL, NULL }; //bla bla // Exported DLL initialization is run in context of running application extern "C" void WINAPI InitGuiCtrlsDLL() { // create a new CDynLinkLibrary...

using macro defined in header files

I have a macro definition in header file like this: // header.h ARRAY_SZ(a) = ((int) sizeof(a)/sizeof(a[0])); This is defined in some header file, which includes some more header files. Now, i need to use this macro in some source file that has no other reason to include header.h or any other header files included in header.h, so sho...