c++

Coding practice: return by value or by reference in Matrix multiplication?

I'm writing this question with reference to this one which I wrote yesterday. After a little documentation, it seems clear to me that what I wanted to do (and what I believed to be possible) is nearly impossible if not impossible at all. There are several ways to implement it, and since I'm not an experienced programmer, I ask you which ...

When building a DLL file, does the generated LIB file contain the DLL name?

In Visual C++ , when I build a dll , the output files are .dll and .lib. Is the name of the dll built into the .lib file . The reasson I ask this question is : When I built my exe by importing this dll and run the exe , the exe tries to locate the dll to load it in the process address space . As we just specify the library name (.li...

Mounting folder as a drive in vista

Hi I am trying to mount as a drive in vista I am using the following code from msdn example, BOOL bFlag; TCHAR Buf[BUFSIZE]; // temporary buffer for volume name if( argc != 3 ) { _tprintf( TEXT("Usage: %s <mount_point> <volume>\n"), argv[0] ); _tprintf( TEXT("For example, \"%s c:\\mnt\\fdrive\\ f:\\\"\n")...

Expression Evaluation in C++

Hi, I'm writing some excel-like C++ console app for homework. My app should be able to accept formulas for it's cells, for example it should evaluate something like this: Sum(tablename\fieldname[recordnumber], fieldname[recordnumber], ...) tablename\fieldname[recordnumber] points to a cell in another table, fieldname[recordnumber] poi...

C++, windows->linux porting, mapfile problem

Hello. I'm porting a small C++ console application from windows to linux, GCC 4.3.2. When compiling I get strange error that I'm unable to solve. Labels.cpp: In function ‘void DumpSymbols()’: Labels.cpp:68: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’ Labels.cpp:68: error: initializing argument 2 of ‘std::basic_ofstrea...

cannot call base class protected functions?

I cant call protected function in my base class. Why? It looks something like this: class B : B2 { public: virtual f1(B*)=0; protected: virtual f2(B*) { codehere(); } } class D : public B { public: virtual f1(B*b) { return f2(b); } protected: virtual f2(B*b) { return b->f2(this); } } In msvc I get the error error C2248: 'name:...

Create temp dir that is globally known and that gets automagically removed (C++)?

In C++, I have a few functions that need to write to a temp directory. Ideally, only one temp directory gets created that they all write to (to minimize I/O overhead). That directory should be automagically removed when the program exits. However, I don't want to deal with creation and removal of the temp directory in the main function ...

Visual C++ express 2008: Why does it places megs of null bytes at the end of the release executable?

Recently I have discovered that my release executable (made with msvc++ express 2008) becomes very large. As I examine the executable with a hex viewer I saw that only the first 300k bytes contains useful data the remaining bytes are only zeros - 6 megs of zero bytes. The debug built exe has 1MB size, but the release is 6.5MB. Why doe...

POCO C++ libraries on CDT

I am working with CDT (C/C++ for eclipse) on windows, and I need to start using POCO C++ libraries The current package distribution for POCO requires MS Visual Studio 7/8/9 for compiling the libs. Does anyone know a solution for compiling in a CDT environment on windows? I am using MinGW for compile/build tools. ...

Passing custom objects between C# and unmanaged C++

I have a legacy DLL which contains a couple of methods I need to call from C# code. One of these methods takes in a pointer to another C++ class that lives within other C++ programs, not the DLL. I'm pretty sure I need to use pinvoke to marshal the objects back and forth, but I haven't found anything on marshaling custom objects. ...

How can I make the program I wrote with QT4 execute when I launch it not from IDE?

When I run the program from IDE (VS2008) it works perfectly. When I want to launch it from Windows Commander it doesn't work because it needs DLL that wasn't found. Used both debug and release builds. ...

How to autodetect urls in RichEdit 2.0?

When we have a RichEdit control and send it an EM_AUTOURLDETECT message with WPARAM set to TRUE, it nicely hightlights the detected URLs and sends the EN_LINK notifications. But it does this only for text that is entered into the control. I haven't found the way to do it for text that's loaded into the control with SetWindowText or EM_ST...

Creating files in C++

I want to create a file using C++, but I have no idea how to do it. For example I want to create a text file named Hello.txt. Can anyone help me? ...

How to create an efficient 2D grid in C++?

Hi, I want to create a really easy to use 2D Grid. Each cell in the grid needs to be able to store a load of data. Ideally I would like to be able to traverse through the grid one cell at a time, as well as obtain the immediate neighbours of any of the grid cells. My first thought was to store a vector of pointers to a Cell's neighbour...

Where to look for contributors?

I've been recently confronted with a not so typical programming problem. Where do I look for contributors? I'm extending an already existing project, Hypertable, and I'm looking for a one or two more people to lend a hand in implementing some stuff. The extension to the project I'm working on is a MapReduce framework which once done will...

Why is this cin reading jammed?

Hi, I've singled out a failure on my program that prevents me from assigning a value to the variable addAntonymAnswer1. I've tried running cin.clear() before the statement to get the thing read my yes/no answer, but the code just won't respond. The program bit that's failing is located inside void dictionaryMenu(vector <WordInfo> &word...

How do I write a C++ program that will easily compile in Linux and Windows?

I am making a C++ program. One of my biggest annoyances with C++ is its supposed platform independence. You all probably know that it is pretty much impossible to compile a Linux C++ program in Windows and a Windows one to Linux without a deluge of cryptic errors and platform specific include files. Of course you can always switch to ...

C++, win32, gdi Printing: DrawEdge does not reach as far as DrawText?

I am trying to print (using a printer, on paper, not on a screen) lines and text, using the the function DrawEdge and DrawText (http://msdn.microsoft.com/en-us/library/ms534882.aspx and http://msdn.microsoft.com/en-us/library/ms533909.aspx). They work quite fine, however, when I try to reach the bottom of my paper (about 35 milimeter awa...

Express the usage of C++ arguments through method interfaces

Is there a common way to express the usage of arguments in C++? I want to implicitly tell the consumers of my class how the arguments they pass will be used by the class. Examples: I own your argument (will clean it up) I will hold a reference to your argument during my lifetime (so you should NOT delete it while I'm stile alive) I w...

Boost Serialization using polymorphic archives

I am working on a client-server application that uses boost::serialization library for it's serialization needs. I need to serialize and deserialize polymorphic objects that does not seem to work. The documentation does say that it is supported but none of the related examples demonstrate what I'm trying to do here. So, I am not very ...