c++

Namespace class and struct

I have a file that looks like this: namespace myName { typedef HRESULT (*PFN_HANDLE)(myName::myStruct); class MyClass{ //... public: BOOL RegisterCallback (PFN_HANDLE foo); //... }; struct myStruct{ //... }; } But I am getting a compile error 'myStruct' is not a member of 'myName'. Can anyone tell me what is go...

Good online C++ syntax reference?

Do you know of a precise and concise online C++ syntax reference? Please provide the link... ...

Free memory debugger for Windows?

I am looking for a free memory debugger for Windows, suited for debugging C++ applications built with VC, with similiar functionality to Insure++ or Purify. Any recomendations? GUI is a plus Integration with VS is a bigger plus ...

Browsing Source Code on an iPhone

I'm the kind of dork who enjoys reading source code in his spare time. I'm also the kind of dork who has an iPhone. What is the best way to read and browse code on such a device? My initial thought is to use something like LXR to generate hyperlinked pages, and upload them to my personal server, but I am interested in better/easier ways...

visual studio - invalid std::string debugger output in Release mode

There's nothing fancy going on in this program, but I get garbage output. Here are the header files I'm including, in case that's relevant. #include <cstdlib> #include <iostream> #include <windows.h> #include <vector> #include <string> #include <sstream> And I'm using Visual Studio 2008 on Windows XP. Note that if I print the strin...

Which is more efficient when initializing a primitive type?

When declaring primitives does it matter if I use the assignment operator or copy constructor? Which one gives the optimal performance, or do most compilers today compile these two statements to the same machine code? int i = 1; int j( 1 ); ...

Templated operator<< explicit instantiation and header

Typically for my templated classes, I include declarations in a .hpp file and templated implementation code in a .t.hpp file. I explicitly instantiate the class in a .cpp file: template class MyClass< AnotherClass >; whose object code gets put in a library. The problem is that if I try to print the object with operator<<, which is de...

C++ - Why am i getting SIGTRAP during the execution ?

Hi, While running, my program often stops because of a SIGTRAP. I know, that a SIGTRAP is happening when the compiler finds a breakpoint in the program. But i don't have any breakpoint in my code. (To be sure about it, before the execution, i cleared all the breakpoints..). I'm using Code::Blocks.. Thanks ! ...

How to explicitly set taskbar icon?

In Visual Studio I generated a plain old Win32 application and stripped all the resources and generated code so that my application consists of this: #include "stdafx.h" #include "IcoTest.h" int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int ...

Using Delphi to creating Win7 Jump list

I'm trying to create Jump list on windows 7 for my application using Delphi. I found this c++ code, but I'm not sure how to translate it to Delphi, any help? void CreateJumpList() { ICustomDestinationList *pcdl; HRESULT hr = CoCreateInstance (CLSID_DestinationList, ...

Structured solution without using a jump statement

From Schaums C++ text Removal of goto- says use a flag code segment: const int N2 = 5; int i, j, k; for (i = 0; i < N2; i++) { for (j = 0; j < N2; j++) { for (k = 0; k < N2; k++) if (i + j + k > N2) goto esc; else cout << i + j + k << " "; cout << "* "; } esc: cout << "." << e...

Digital copy of the C++ standard?

Does anyone know where I can get an digital copy of the C++ standard for download? My google-fu does not appear to be strong enough. ...

Using != with counter controlled loops

Last question for today all...I will get back with tomorrow..I have a lot to follow up on... I am looking in Reilly Java text- talking about counter controlled loop patterns..(does not matter what language..) The author for counter controlled loops (for, while, etc) and with nesting loops...uses the != for test...Now I realize != is us...

How can I tell if an object is statically or dynamically allocated on the constructor?

I have an object that requires a slightly different construction wether it's instance is staticly or dynamically allocated. The object should only have a single default constructor. So having two constructors, one for each case, and having the user explicitly select the proper constructor is out of the question. Is there any proper way ...

HTTP inputstream class (C++)

I'm currently working on a project that does a lot of HTTP requests for data that it needs. It works by writing all the data into a buffer, then returning that buffer to the caller. It seems that waiting for the entire file to download data that can essentially streamed is a bad idea. Question 1: Is there already a library / public code...

Right way to conditionally initialize a C++ member variable?

Hi, I'm sure this is a really simple question. The following code shows what I'm trying to do: class MemberClass { public: MemberClass(int abc){ } }; class MyClass { public: MemberClass m_class; MyClass(int xyz) { if(xyz == 42) m_class = MemberClass(12); else m_class = MemberClass(32...

Static class members in shared library

I have a class like class K { static int a; static int b; } I would like to create a shared library (dll) containing this class K. In a cpp file compliled in the library I call int K::a = 0; int K::b = 0; to instantiate the static variables. The dll does compile without errors, but when I use the library, I get the unresolved e...

mfc copy certain sections of a CString

Let's say I have a CString variable carrying the string "Bob Evans". I want to copy from position 4 until the end of the original CString to a new CString, but I am having trouble finding semantics examples for this: CString original("Bob Evans"); // Below is what I'm trying to do // CString newStr = original.copy(4, original.GetLength(...

Force Java to call my C++ destructor (JNI)

I thought this question would have been asked before, but I couldn't find it here... I've used SWIG to create a JNI wrapper around a C++ class. All works great except that Java never seems to call the class's finalize(), so, in turn, my class's destructor never gets called. The class's destructor does some final file I/O, so unfortunate...

error PRJ0019: A tool returned an error code from "Copying DLL..."

Visual studio is giving the error PRJ0019: A tool returned an error code from "Copying DLL...". The console window includes the output: 'CopyDLL.cmd' is not recognized as an internal or external command. Here is some background as to why I don't know about the tool which is copying. Someone left the company a year ago and forgot to chec...