c++

How to detect if application is memory bound ?

How to detect if an application is memory bound ? Is there some kind of pattern or a tool ? Mostly for C++ and C# applications... I don't think that there is such a tool in Microsoft Visual Studio. ...

Standard behavior of tellp on empty ostringstream

I have a question on the standard behavior of calling tellp on an empty ostringstream. I have a function foo which calls tellp the first thing: void foo(std::ostream& os) { std::ostream::pos_type pos = os.tellp(); // do some stuff. } int main() { std::ostringstream os; foo(os); } In Visual Studio 2005, calling this fu...

Smart tool (addin?) for creating class body from header file

Hi, you probably know this -- you're going to create some nice class, you think about it a little, maybe even draw a little UML here and there and then you're ready for implementation. You create header files with member functions, maybe even some member properties. And now comes the dull work -- rewriting everything into .cpp file. It...

Using C code from C++ using autotools

I am writing a (my first) C++ class on top of some code written in C, but I can only get the C++ to compile by declaring the C functions in a extern block. My project uses autotools; is there any way to automate this process so I don't have to maintain two header files? ...

modify an open file c++

Under Windows is there a way to modify a file/executable opened by another process using c++? ...

Just started C++: Undefined Symbol error on Compile

Here's the situation: I just started my first C++ class. I know nothing about C++ and despite this being the an intro to C++ class, the teacher has taught pretty much NO syntax for the language, just logic that we already know. Now he gave us a program description and said, "write it, lol." I understand the logic fine, but as I said be...

Set QLineEdit focus in Qt

I am having a qt question. I want the QLineEdit widget to have the focus at application startup. Take the following code for example: #include <QtGui/QApplication> #include <QtGui/QHBoxLayout> #include <QtGui/QPushButton> #include <QtGui/QLineEdit> #include <QtGui/QFont> int main(int argc, char *argv[]) { QApplication app(argc,...

Good tools for creating a C/C++ parser/analyzer

What are some good tools for getting a quick start for parsing and analyzing C/C++ code? In particular, I'm looking for open source tools that handle the C/C++ preprocessor and language. Preferably, these tools would use lex/yacc (or flex/bison) for the grammar, and not be too complicated. They should handle the latest ANSI C/C++ defi...

First C++ Program Ever: Compile Errors

I was having some problems with my first C++ program (this one) awhile ago. Basically I am trying to do an assignment for intro to C++ class where the professor has taught us no syntax. Here is my code right now: #include <cstdlib> #include <ctime> #include <iostream> #include <string> using namespace std; class Race { public: ...

How should I deploy an MFC application?

I created an application in VS 2008 Express as an MFC app just to take advantage of the easy GUI creation. I might re-do this app in pure win32 since no other MFC classes are used (just a button and a text box, the button fires off the main program, all win32). My only question that determines whether I stay in MFC or port it over to pur...

Creating a new vector using a transform

I have a vector of integers and I want to convert it to a vector of pairs (pair consists of a bool and a int). My current code is simple like this: std::vector<int> a; std::vector<std::pair<bool,int> > b; a.push_back(1); a.push_back(2); a.push_back(3); for(int i = 0; i < a.size(); ++i) { b.push_back(st...

how boost::function and boost::bind work

I dislike haveing magic boxes scattered all over my code...how exactly do these two classes work to allow basicly any function to be mapped to a function object even if the function<> has a completly diffrent parameter set to the one im passing to boost::bind It even works with diffrent calling conventions (ie member methods are __thisc...

Optimising Iterator Definitions

Hi all, This is a (hopefully) really simple question - I have been told recently that using C++ style initialisation is better than traditional (and more common) assignment. So this code: std::SomeSTLContainer::const_iterator it = container.begin(); std::SomeSTLContainer::const_iterator itEnd = container.end(); would be 'slower' or ...

Which language to learn: C, C# or C++?

I'm want to learn one of the above languages. I'm a PHP/HTML/CSS programmer and I would like to get into desktop applications. I need something pretty powerful and I would like to be able to create applications with Windows GUI's. What would the Stack Overflow community recommend? Is there any knowledge I should have before diving into...

Windows Subclassing in Borland C++ Builder

We're trying to convert a piece of C++ code written in MFC which uses the CWnd.SubclassWindow method, into Borland C++ Builder code. Does anyone know how to do subclassing (subclass with a TForm object) - we're completely stuck. Any pointers will be much appreciated! TIA! Specifics: We have an existing base class written in Borland C++...

Overloading operator<< for primitive types. Is that possible?

Hey. Is it possible to overload operator<< for primitive types? Fx lets say that I want to write a std::endl each time want to write a int. Can I overload operator<< for int, so that it automatic puts a std::endl to the output? I have tried with this, std::ostream& operator<<(std::ostream& strm, int & i) { strm << i << std::endl; ...

C/C++ optimize data structures, array of arrays or just array

Working with a program that uses 16bytes 4v4 one byte matrices : unsigned char matrix[4][4]; and a few 256bytes 16v16 one byte matrices: unsigned char bigMatrix[16][16]; Very often due to data manipulation I am forced to loop column wise in the program making cache misses. Will the performance improve if I use an array instead, i....

Is it OK to use C-style cast for built-in types?

After reading here a lot of answers about C-style casting in C++ I still have one little question. Can I use C-style casting for built-in types like long x=(long)y; or it's still considered bad and dangerous? ...

Is it possible to use boost library in visual studio 2008 64 bit version?

I tried to use boost library in 64 bit mode of VS2008 but I'm getting "header file not found" errors. is it any possible to use boost library under 64 bit mode of VS2008? it worked fine in 32 bit mode. that's why I'm suspicuous bout 64 but ;( Or anybody have good link to show setting up 64 bit mode to use boost? thanks ...

Compiler Error with const function

I am not sure whether I am missing something basic. But I am unable to understand why the compiler is generating the error for this code: class A { }; class B { public: B(); A* get() const; private: A* m_p; }; B::B() { m_p = new A; } A* B::get() const { //This is compiling fine return m_p; } class C { public...