c++

How Do You Create Test Objects For Third Party Legacy Code

I have a code base where many of the classes I implement derive from classes that are provided by other divisions of my company. Working with these other devisions often have the working relationship as though they are third party middle ware vendors. I'm trying to write test code without modifying these base classes. However, there are...

Can you make Visual Studio 2005 provide command line arguments for your startup program?

For testing purposes, is there some place in the Visual Studio IDE where you can specify the command line parameters that you want sent to your startup project when it's launched from the IDE? Thanks in advance for all your help! ...

Convert MYSQL_TIME data type to char * or C++ string

I am using the MySQL C API within a C++ application. I have a column in my result set that is of the type MYSQL_TIME (part of mysql.h). Is there a way to convert MYSQL_TIME to a char* or to a C++ string? ...

What make g++ include GLIBCXX_3.4.9?

I compiled 2 different binaries on the same GNU/Linux server using g++ version 4.2.3. The first one uses: GLIBC_2.0 GLIBC_2.2 GLIBC_2.1 GLIBCXX_3.4 GLIBC_2.1.3 The second one uses: GLIBC_2.0 GLIBC_2.2 GLIBC_2.1 GLIBCXX_3.4.9 GLIBCXX_3.4 GLIBC_2.1.3 Why the second binary uses GLIBCXX_3.4.9 that is only available on libstdc++.so.6.0...

Is endian conversion required for wchar_t data?

In C/C++, if a multi-byte wide character (wchar_t) value is transmitted from a big-endian system to a little-endian system (or vice-versa), will it come out the same value on the other side? Or will the bytes need to be swapped? ...

Best way to extract a subvector from a vector?

Suppose I have a std::vector (let's call it myVec) of size N. What's the simplest way to construct a new vector consisting of a copy of elements X through Y, where 0 <= X <= Y <= N-1? For example, myVec [100000] through myVec [100999] in a vector of size 150000. If this cannot be done efficiently with a vector, is there another STL da...

C/C++: Capture characters from standard input without waiting for enter to be pressed

I can never remember how I do this because it comes up so infrequently for me. But in C or C++, what is the best way to read a character from standard input without waiting for a newline (press enter). Also ideally it wouldn't echo the input character to the screen. I just want to capture keystrokes with out effecting the console screen...

CEditView not showing text

I have a view which is derived from CEditView. It is read only. I would like to set the text as a kind of logging, but nothing shows up on the screen. If I inspect temp in the debugger after GetEditCtrl().GetWindowText(temp); I can see that the text is indeed changing internally, but I see nothing on the screen. // HistoryView.cpp : ...

Stop and start running again processes in Linux using C++

Hello, I have two process and a shared memory zone, my workflow is like this. The process A write some data in the shared memory, after that it should wait and send a signal to other process B to start running. The process B should read some data from the shared memory do some stuff write the result, and send a signal to the process A t...

Memory Allocation in Recursive C++ Calls

Hi, I'm having problems allocating and deallocating my memory in a recursive C++ program. So without using an automatic memory management solution, I wonder if anyone can help me resolve the memory leak I am experiencing. The following code essentially explains the problem (although it's a contrived example, please correct any mistakes...

Derivatives in C/C++?

I have some expressions such as x^2+y^2 that I'd like to use for some math calculations. On of the things I'd like to do is to take partial derivatives of the expressions. So if f(x,y) = x^2 + y^2 then the partial of f with respect to x would be 2x, the partial with respect to y would be 2y. I wrote a dinky function using a finite differ...

Canonical operator overloading?

Is there a canonical or recommended pattern for implementing arithmetic operator overloading in C++ number-like classes? From the C++ FAQ, we have an exception-safe assignment operator that avoids most problems: class NumberImpl; class Number { NumberImpl *Impl; ... }; Number& Number::operator=(const Number &rhs) { NumberIm...

Visual Studio _CrtDumpMemoryLeaks always skipping object dump.

Hi, I'm trying to use the CRT memory leak detection but I keep getting the following message in Microsoft Visual Studio: "Detected memory leaks - skipping object dump." I can never get the it to actually do and object dump. I followed the directions in the Microsoft article on Memory Leak Detection (http://msdn.microsoft.com/en-us/libra...

Does any tool similar to NDepend exist for unmanaged C++ code?

I have enjoyed the power of NDepend ( http://www.ndepend.com/ ) when writing C#, but in my C++ projects I have not found a comparable tool. I use Visual Studio 2005, which has a class-view that covers some bases, but it is not powerful enough and doesn't work across project boundaries. I use Visual Assist X, which has some powerful refa...

C++ How can I get a return a reference and save the refence as a local variable in a function?

I have a function inside a class that returns a reference to a member variable. std::vector<uint8> & getBuffer() const { return m_myBuffer; } Now say in another class I call this method: int someFunction() { std::vector<uint8> myFileBuffer = myFile.getBuffer(); } This line calls the copy constructor of vector and makes me a l...

Structure of a C++ Object in Memory Vs a Struct

If I have a class as follows class Example_Class { private: int x; int y; public: Example_Class() { x = 8; y = 9; } ~Example_Class() { } }; And a struct as follows struct { int x; int y; } example_struct; Is the...

How is it possible to resolve unresolved symbols (LNK2001) for _RTC_InitData and _RTC_Shutdown

I am building an x64 lib in Visual Studio 2008, and separately linking it into an x64 DLL (specifically using the WDK Build.exe toolchain in this case). Most general C runtime symbols link fine, indicating that the library versions are sufficiently well-matched, but these two RTC_* symbols specifically fail. Forcing different runtime lib...

std::list with std::map properties?

Basically, I want to have a std::list but with std::map properties such as find(), do I really need to loop through every single list entry to find what I need? ...

Is this dynamic memory allocation?

Simple question: do I have to 'delete' or 'delete []' c? Does the language matter? char c[] = "hello" ...

Wrap/encrypt another executable (for licensing)

I want to create a wrapper around another executable (ie - I have an executable that prints hello World, but I want the user to enter a password before the hello world executable is run). I don't want to edit the original executable's source. I also want to encrypt the original executable (hello world in this example) and do not want to...