c++

Why is my overloaded C++ constructor not called?

Hi, I have a class like this one: class Test{ public: Test(string value); Test(bool value); }; If I create an object like this: Test test("Just a test..."); The bool constructor is called! Anyone knows why? Thanks ...

Storing elements in the list, in the ascending order

Goal is, I've multiple lists of elements available, and I want to be able to store all of these elements into a resultant list in an ordered way. Some of the ideas that comes to my mind are a) Keep the result as a set (std::set), but the B-tree , needs to rebalanced every now and then. b) Store all the elements in a list and sort the li...

The difference between Call Gate, Interrupt Gate, Trap Gate?

I am studying Intel Protected Mode. I found that Call Gate, Interrupt Gate, Trap Gate are almost the same. In fact, besides that Call Gate has the fields for parameter counter, and that these 3 gates have different type fields, they are identical in all other fields. As to their functions, they are all used to transfer code control into...

Help - trying to marshall c++ char* to a .NET callback function...

Hello, i have a c++ dll that contains a function called DoIt : int WINAPI DoIt() { SetCallback(pCallbackFunc); LPSTR pRet = (LPSTR) LocalAlloc(LPTR, 1024); memset(pRet, 0, 1024); g_CALLBACK(pRet); MessageBoxA(0,(LPSTR)pRet,"response",MB_ICONEXCLAMATION); LocalFree(pRet); return 1; } as you can see, this func...

how to run a batch file using c++?

how to run a batch file using c++? I dont know any thing about that ...

varargs function crashing

I have a function that is supposed to take a variable number of arguments (using varargs) based on a format string: void va(const char* name, const char* argformat, ...) { int numOfArgs = strlen(argformat); std::string buf = "asdf"; va_list listPointer; va_start(listPointer, numOfArgs); char* blah; for(int i =...

How to detect points which are drastically different than their neighbours

Hey I'm doing some image processing, and am trying to keep track of points similar to those circled below, a very dark spot of a couple of pixels diameter, with all neighbouring pixels being bright. I'm sure there are algorithms and methods which are designed for this, but I just don't know what they are. I don't think edge detection wo...

Using BFD with MinGW

Hi all, i actually trying to compile an application that uses bfd library (a part of beanutils) using MinGW. I've added the libiconv 1.13 and gettext 0.17 packages to my MinGW directory. If i compile my source including bfd: $ g++ iftest.cpp -o iftest -llibiconv -lbfd -liberty This leads to the following linkage error: c:/binrev/dev...

Proper handling of GetLastError (and others) in a multithreaded context.

Is it correct to assume that GetLastError (and variants) are per-thread or is it per-process? The problems if it is per-process are somewhat obvious in multithreaded apps because there is no way to guarentee that no other Win32 calls were made between your failed call and GetLastError. Sometimes the value of GetLastError is important. ...

How to mock templated methods using Google Mock ?

I am very new to Google Mock and to StackOverflow, sorry in advance if my question is not well posed. I am trying to mock a templated method. Here is the class containing the method to mock : class myClass { public: virtual ~myClass() {} template<typename T> void myMethod(T param); } How can I mock the method myMethod u...

static char * vs #define in C++ VS2005

I have a large program with several large DLL's that are compiled with MFC and /clr. There is a limit of 65535 global FieldRVA entries in an assembly. If it is more the loader raises an exception. I already have Enable String Pooling (/GF). I have alot of code like: static char *pSTRING_ONE = "STRING_ONE"; if I compile witha macro su...

C++ IDE Suggestions?

Possible Duplicate: C++ IDE for Linux? For the past few years I have been using Eclipse, and have come accustomed to the auto-complete feature. I havent done much c/c++ dev, and wanted to see peoples experiences with what IDEs work best - specifically with a need for an auto-complete feature, as well as the ability to run on ...

Is using double faster than float?

Double values store higher precision and are double the size of a float, but are Intel CPUs optimized for floats? That is, are double operations just as fast or faster than float operations for +, -, *, and /? Does the answer change for 64-bit architectures? ...

Do classes with uninitialized pointers have undefined behavior?

class someClass { public: int* ptr2Int; }; Is this a valid class (yes it compiles)? Provided one assigns a value to ptr2Int before dereferencing it, is the class guaranteed to work as one would expect? ...

Child class as return type for a class method.

I have a C++ class which is meant to be inherited. All its children will inherit a method: class Record { public: RETTYPE* all(); }; class Child : public Record { int age; char *name; }; int main() { Child boo; Child boos* = boo->all(); // Pointer to array of Children return 0; }; How can I make a method retu...

Why does WinAPI's GetSystemInfo tell that my quad-core machine has 8 cores?

I'm trying to find out how to get the number of CPU cores programmatically. This is the code I'm using: SYSTEM_INFO sysinfo; GetSystemInfo( &sysinfo ); std::cout << "CPU count: " << sysinfo.dwNumberOfProcessors << std::endl; This is running on Windows on the iMac i7 via Boot Camp. It would be nice to find out that Apple made a manufac...

Is atomic CAS required when setting a boolean to true

I have class where a bool is access concurrently. However in my case it is only initialized to false once in the constructor, and after that it set to false. Am i correct to believe that even though a race might occur the result will be valid and defined? Since the entire bool doesn't have to be written to inorder for "!isStopping_" to ...

Crypto Next Generation API cross-platform compatibility issues

My problem is that I've written an application entirely using CNG on Windows 7, and now I have to port it backwards to Vista. Vista has CNG of course, but the SSL provider is an older version and is not always compatible - for example it won't import opaque keys exported from the Win7 version of the same provider. E.g. this code works ...

instant messaging program - works with 127.0.0.1, but not with other computers

I have followed a tutorial on http://www.codeproject.com/KB/IP/beginningtcp_cpp.aspxt which teaches how to use winsockets with c++, i finally managed to get my program to work, by testing wiht 127.0.0.1, i can open two process instances of my program and then make one listen on port (700) and then connect to it with the other program on...

How can I compress a wide character stream using boost::iostreams?

Hello everyone, I'm working with some code which writes to a wostream. I'd like take its output and write it to a gzip'ed file. This seemed like a good job for boost::iostreams. However, my attempts so far at this haven't been successful. (in all the below, assume using namespace boost::iostreams and that I have some function void my_...