c++

C++ object in memory

Hello. Is there a standard in storing a C++ objects in memory? I wish to set a char* pointer to a certain address in memory, so that I can read certain objects' variables directly from the memory byte by byte. When I am using Dev C++, the variables are stored one by one right in the memory address of an object in the order that they were...

Adding an inheritance to an Qt designed object

Hello, I have a problem and I want to implement the MVC pattern to my QT application, that's why I need for example to inherite in my QTableWidget about another class like myClass { myMethod(); } but our QTableWidget is contained by our Mainwidows that is designed by the QT designer and generate an ui_MainWindow class ! Do you ...

GCC, Unicode and __FUNCTION__

I'm trying to make my project compile under GCC (Visual Studio compiles it flawlessly). I have a custom assert function which throws a wstring message. A part of it is the _ FUNCTION_ macro, which I "unicodize" using the WIDEN macro from MSDN #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) It compiles okay in MSVC, but it prints ...

How to transform a vector<int> into a string?

I am trying to pass a value from C++ to TCL. As I cannot pass pointers without the use of some complicated modules, I was thinking of converting a vector to a char array and then passing this as a null terminated string (which is relatively easy). I have a vector as follows: 12, 32, 42, 84 which I want to convert into something l...

question regarding templatization of virtual function

I know that you cannot templatize a virtual function and I do understand the concept behind it. But I still need a way to get past some errors I am getting. I am able to make my stuff work, but it doesn't look right to me. I have class called System: #include "Vector.h" class System { virtual void VectorToLocal(Vector<T>& global_d...

C++ method parameter passed by reference - memory question

Assume, void proc(CString& str) { str = "123"; } void runningMethod() { CString str="ABC"; proc(str); } I understand that at the exit of runningMethod str will be deallocated automatically; in this case, how does C++ delete the old data ("ABC")? Thanks, Gil. ...

Reading value at an address

I'm trying to make a program that reads the value at a certain address. I have this: int _tmain(int argc, _TCHAR* argv[]) { int *address; address = (int*)0x00000021; cout << *address; return 0; } But this gives a read violation error. What am I doing wrong? Thanks ...

how to write programs using advanced OpenType features?

How could I write a simple program using OpenType tables in order to dynamically render text? please answer in : assembly , C , C++ , C# , java or Python (and a little WPF:-) or introduce libraries of them. comments and answers about text rendering system of common Operating Systems, or designing text engines compatible with unic...

Debugging unmanaged code while debugging managed code

Hi, The .NET 3.5 application I am working on consists of bunch of different solutions. Some of these solutions consist of managed code(C#) and others have unmanaged code(C++). Methods written in C# communicate with the ones written in C++. I am trying to trace the dependencies between these various functions and I thought setting breakp...

c++0x, std::thread error (thread not member of std)

Hello I compiled & installed gcc4.4 using macports. When I try to compile using -> g++ -g -Wall -ansi -pthread -std=c++0x main.cpp...: #include <thread> ... std::thread t(handle); t.join(); .... The compiler returns: cserver.cpp: In member function 'int CServer::run()': cserver.cpp:48: error: 'thread' is not a member of 'st...

isalpha(<mychar>) == true evaluates to false??

string temp is equal to "ZERO:\t.WORD\t1" from my debugger. (the first line of my file) string temp = RemoveWhiteSpace(data); int i = 0; if ( temp.length() > 0 && isalpha(temp[0]) ) cout << "without true worked" << endl; if ( temp.length() > 0 && isalpha(temp[0]) == true ) cout << "with true worked" << endl; This is my code t...

Trouble calculating correct decimal digits.

I am trying to create a program that will do some simple calculations, but am having trouble with the program not doing the correct math, or placing the decimal correctly, or something. Some other people I asked cannot figure it out either. Here is the code: http://pastie.org/887352 When you enter the following data: Weekly Wage: 500...

Linking Boost to my C++ project in Eclipse

I'm trying to get the Boost library working in my C++ projects in Eclipse. I can successfully build when using header-only libraries in Boost such as the example simple program in the "Getting Started" guide using the lambda header. I cannot get my project to successfully link to the regex Boost library as shown later in the guide. Unde...

How to deal with Warning C4100 in Visual Studio 2008

For some reason my Visual Studio 2008 began to show warnings for code like: "int main( int argc, char **argv)", which is really annoying. The detailed warning ouputs are (you can ignore the line numbers): 1>.\main.cpp(86) : warning C4100: 'argv' : unreferenced formal parameter 1>.\main.cpp(86) : warning C4100: 'argc' : unreferenced fo...

Why are structs not allowed in template definitions?

The following code yields an error error: ‘struct Foo’ is not a valid type for a template constant parameter: template <struct Foo> struct Bar { }; Why is that so? template <class Foo> struct Bar { }; works perfectly fine and even accepts an struct as argument. ...

How to link to dynamic boost libs?

I compiled boost lib and got these. //Shared/dynamic link libraries 24/03/2010 11:25 PM 53,248 boost_thread-vc80-mt-1_42.dll 24/03/2010 11:25 PM 17,054 boost_thread-vc80-mt-1_42.lib 24/03/2010 11:25 PM 17,054 boost_thread-vc80-mt.lib 24/03/2010 11:25 PM 73,728 boost_thread-vc80-mt-gd-1_...

ImageMagick static compilation with another project gives linker errors

I've downloaded the ImageMagick source, compiled the wizard to create a Visual Studio solution for static linkage, and included the static library Magick++ project in my sample project (code below). I've also added a dependency on that project and included the .lib file in the solution, nothing helps. #include <Magick++.h> int main() {...

setcontext and makecontext to call a generic function pointer

In another question i had the problem to port the code unsigned long stack[] = { 1, 23, 33, 43 }; /* save all the registers and the stack pointer */ unsigned long esp; asm __volatile__ ( "pusha" ); asm __volatile__ ( "mov %%esp, %0" :"=m" (esp)); for( i = 0; i < sizeof(stack); i++ ){ unsigned long val = stack[i]; asm __volatil...

How to cope with "intrin.h: No such file or directory"?

#include <intrin.h> The above will report: intrin.h: No such file or directory Which seems to be a MSVC header file,but I'm using eclipse cdt,how can I make it available?Is there some libraries needed? cdt uses MinGW for compiling,but there is no intrin.h: D:\Tools\MinGW\lib\gcc\mingw32\3.4.5\include>dir *intrin.h 2006-01-17 21:...

operator new for array of class without default constructor......

For a class without default constructor, operator new and placement new can be used to declare an array of such class. When I read the code in More Effective C++, I found the code as below(I modified some part)..... My question is, why [] after the operator new is needed? I test it without it, it still works. Can any body explain th...