c++

Vim Editor is very smart?

I am programming in C++ or Java. So I want to use Vim editor, because it is very flexible. I have heard that I can configure the Vim editor to be able to go from object to the definition from function to the definition from class name to the definition Do we have any professional Vim-er that could tell me how exactly to configure Vim...

Qsort based on a column in a c-string?

A class project involves sorting an array of strings, with each string containing an equal number of columns like this: Cartwright Wendy 93 Williamson Mark 81 Thompson Mark 100 Anderson John 76 Turner Dennis 56 The program accepts a command-line argument for which column to sort on, and should print ou...

Ideas to debug and solve a very sporadic crash - appears to be an AV

Hi, I have a bug somewhere that is causing my app to just vanish without an error message or something like that. The app just dissapears from the screen and it's no longer listed on the Task Manager. The app is a C++Builder app (CBuilder2007), and I have tried everything I have think of to try to catch this error. It happens very very...

how to simulate press any key to continue?

Hi, I am trying to do a C++ program where when user enter any character from keyboard it should move to next line of code. Here is my code: char c; cin>>c; cout<<"Something"<<endl; but this is not working because it only move to next line when i input some character and then press ENTER. OR If i use this cin.get() or cin.get(c)...

Heap Corruption, Possible Memory Leaks, C++

I have a homework assignment that I've nearly completed. As inefficient as it is be I was just wanting to know how I can prevent a crash when my program ends. quack::quack(int capacity) : backPtr( NULL ), frontPtr( NULL ) { items = new item[capacity]; backPtr = new item; frontPtr = new item; midPtr = new item; cu...

Message loop gets blocked when application menu has the focus

Hi, I'm developing an application that looks mainly like this: while (true) { while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } DoSomething(); Sleep(1); } What I noticed is that DoSomething() doesn't get called when I click on the menu bar (displaying ...

Threading a member function inside a vector of classes

Hello, consider this: class MyClass { public: void DoSomething() { }; }; std::vector<MyClass> A; int main(int argc, char* const argv[]) { MyClass a; A.push_back(a); boost::thread newThread(&MyClass::DoSomething, &A.back()); } It compiles, but, expectedly, it does not work. Any help? ...

c++ operator overloading memory question

In c++ you can create new instances of a class on both the heap and stack. When overloading an operator are you able to instantiate on the stack in a way that makes sense? As I understood it an instance that sits on the stack is removed as soon as the function is done executing. This makes it seems as though returning a new instance sit...

how to append a list<T> object to another

in C++, I have two list<T> objects A and B and I want to add all the members of B to the end of A. I've searched a few different sources and haven't found a simple solution (e.i. A.append(B);) and this surprises me a bit. What is the best way to do this? As it happens, I don't care about B after this (it gets deleted in the very next l...

Formatting C++ Console Output.

I've been trying to format the output to the console for the longest time and nothing is really happening. I've been trying to use as much of iomanip as I can and the ofstream& out functions. void list::displayByName(ostream& out) const { node *current_node = headByName; // I have these outside the loop so I dont write it everytime....

Multiple Inheritance and Duck Typing

In working on Kira3, I was playing around with the C++ compiler and looking for a good way of implement Kira's duck typing. I was hoping (as it has been a few years of direct C++ programming) that I could use multiple inheritance for member access under multiple types. Alas, I have failed so far... The ideal code would look like: class...

openGL and STL?

hi, I am using openGL and am currently passing it a vertex array. The problem is that I have to create many vertices, and add them in between one another (for order). This means that using a regular array is pretty annoying/inefficient. I want to use a data structure from STL so that I can efficiently (and easily) put new vertices at a...

Code that compiles for the iPhone Device but not for the Simulator

I am using C++ to develop the algorithmic part of an iPhone application, and I am encountering a strange bug. The code that I have, compiles fine with gcc-4.2 both on Linux, on the Mac, and on the iPhone device, just not on the Simulator, which makes debugging and testing very difficult. The error messages from the attempts to compile ...

What's wrong with this c++ code?

My C++ is a bit rusty so... #include<list> typedef list<int> foo; that gives me the oh so nice error message: test.cpp:2: syntax error before `;' token What the heck can I even Google for in that... ...

Cannot pass string to CreateThread receiver

I have a thread function that looks something like this: DWORD WINAPI Thread_ProcessFile( LPVOID lpParam ) { char *filename = (char*)lpParam; printf( "%s\n", filename ); } I also have a class that calls CreateThread and uses the above function for the routine address: void CMyClass::ProcessFile( void ) { HANDLE tHwnd = 0; char s...

Formatting to the Console, C++

Hi, I'm trying to format my output in the console window in four separate fields, all evenly spaced. out << left << setw(24) << "Name" << "Location" << right << setw(20) << "Acres " << "Rating" << endl; out << left << setw(24) << "----" << "--------" << right << setw(20) << "----- " << "------" << endl; while ( current_node ) {...

MySQL Connector/C++ Library Linking ERROR Problem

PROBLEM: Ok, I've been TRYING to follow the sample code on the MySQL Forge Wiki and some other websites that offer a tutorial on how to get a simple database connection, but for some reason, my project always fails at a linking error and I can't figure out why or how to fix it myself (I'm still learning). PLEASE HELP ME! I've included t...

C++ `argc` and `argv` arguments

Can anyone explain what are and how to use "argc" and "argv"? It seems my new assignment is about "argc" and "argv", but I don't know what they are. -- thanks guys but i still dont understand what's what. these are codes from my revision notes, anyone can explain which is which that has been explained below? class Tank{ public; int...

How to predict the behavior of a system based on previous behavior

I am looking for an algorithm that, based on the previous behavior of a system, predicts the future behavior. I'm building a parallel memory allocator that has a public list of empty blocks. Each thread, when it needs, can take blocks from this list and allocate from them. The blocks are grouped in bins, depending on the allocation si...

Eclipse CDT with Cygwin GCC: automatic discovery of symbols and paths

I am using Eclipse CDT with Cygwin GCC as compiler. My project is using a custom Makefile.The problem is that when debugging the code, it couldnt locate the source files, even though I added a custom path mapping for: /cygdrive/c <-> c:\ That in addition to the fact that I am getting "unresolved inclusion" for all standard header files,...