c++

"Ch++" or "ch+1" in C++?

Hello. While reading "C++ Primer Plus 5th edition", I saw this piece of code: cin.get(ch); ++ch; cout << ch; So, this will lead to display the following character after ch. But, If I did it that way: cin.get(ch); cout << ch+1; Now, cout will think ch is an int(try typecasting). So, why cout does so? And why if I...

Error when passing an object by reference .....

So I have a problem.... I've a method void MainWindow::loadItems(const ArticleStore& store) { } that I try to call like this inside the MainWindow class ArticleStore store(); loadItems(store) And I get this error mainwindow.cpp:15: error: no matching function for call to ‘MainWindow::loadItems(ArticleStore (&)())’ mainwindow...

vtables for derived, concrete, classes

If I have one base class and I derive 10 different concrete derived classes from it then will each and every concrete derived class have a different vtable? ...

Eclipse CDT 5.x and cmake 2.6.x

Hi, According to what I see, cmake 2.6.x supports CDT 4.x. We already have CDT 6.x. Is CDT 5.x and cmake 2.6.x are compatible at least? Thanks Dima ...

Counting the total of same running processes in C++

Hello there, I'm looking for a way to detect the # of running processes that has same process name. In example, I ran notepad three times. notepad.exe notepad.exe notepad.exe So it will return 3. I currently have these code to detect a running process, but not counting its running process quantity. #include <iostream> #include <win...

Problem with using OpenGL's VBO

I just tried to render the first redbook example ( the white Quad ) by using VBOs. It works fine with immediate mode and vertex arrays. But when using VBOs the screen stays black. I think i must have missed something important. init: unsigned int bufIds[2]; glGenBuffers( 2, bufIds ); GLfloat vertices[] = { 0.25, 0.25, 0.0, 0.7...

Eclipse C++ compilation warning problem

Hi, Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1), m_a(2) {} private: int m_a; int m_b; }; This is an output on Console view: make all Building file: ../test.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test.d" -MT"test.d" -o"test.o" "...

Copy files with widestring path in C++

I'm having some trouble using wchar_t* strings for copying a file, how do I open them in C/C++ I need to use wide chars because the filenames are in unicode with different foreign languages. Thanks in advance. ...

Convert a String in C++ Code

Hello, I'm learning C++ and developing a project to practice, but now i want to turn a variable(String) in code, like this, the user have a file that contains C++ code, but i want that my program reads that file and insert it into the code, like this: #include <iostream> #include <fstream> #include <string> #include <cstdlib> using name...

const pointers in STL containers

Hello fellow C++ programmers. I have, what I hope to be, a quick question about STL containers: std::list<std::string> l; This statement compiles fine when used in some C++ sourcefile (with the appropriate includes). But std::list<const std::string> m; or std::list<std::string * const> n; fails to compile when using gcc (gcc ver...

C++ Template Metaprogramming - Is it possible to output the generated code?

I would like to debug some templated code to understand it better. Unfortunately I'm new to template metaprogramming and it IS hard for me to get in. When I try to output the preprocessed source files I get 125 000 lines of code :/ So is there a way I can see the generated Code? (The library I'm using is SeqAn) ...

C++ Getting the size of a type in a macro conditional

Is there some way to do something like this in c++, it seems sizeof cant be used there for some reason? #if sizeof(wchar_t) != 2 #error "wchar_t is expected to be a 16 bit type." #endif ...

Namespace correctness

I'm trying to question my own code correctness on the following minimalist example in which a header file lifts a identifier into the current namespace. #include <string> namespace mine { using std::string; // std::string lifted into mine struct agent { string name; }; } This is a suggestion I made recently ...

Why do we need a pure virtual destructor in C++?

I understand the need for a virtual destructor. But why do we need a pure virtual destructor? In one of the C++ articles, the author has mentioned that we use pure virtual destructor when we want to make a class abstract. But we can make a class abstract by making any of the member functions as pure virtual. So my questions are Wh...

C++ 'small' optimization behaving strangely

I'm trying to optimize 'in the small' on a project of mine. There's a series of array accesses that are individually tiny, but profiling has revealed that these array accesses are where the vast majority of my program is spending its time. So, time to make things faster, since the program takes about an hour to run. I've moved the fol...

Can a C++ dll compiled using Visual Studio 2008 be used with Visual Studio 2005?

I'm going to be working with a C++ library written in plain C++ (not .NET and without MFC). The library is available compiled using both Visual Studio 2005 / Intel Fortran 9.1 and VS 2008 / Intel Fortran 10.1. Obviously I'm going to grab the binaries for VS 2008 since that's the environment on my computer but I'm curious if there are r...

Syntax error in resource file. I don't understand.

Hi all! I have a .rc file: #include "MainWindowResource.h" MAINWINDOW_MENU MENU DISCARDABLE BEGIN POPUP "&File" BEGIN MENUITEM "&New\tCtrl+N", MAINWINDOW_MENU_FILE_NEW MENUITEM "&Open\tCtrl+O", MAINWINDOW_MENU_FILE_OPEN MENUITEM "&Save\tCtrl+S", ...

Build Managment: Eclipse project vs Eclipse Managed Make project

I am developing under Windows, and using Eclipse with CDT to develop C++ applications. Now, for build management I can create a normal C++ project and Eclipse will completely manage the build (calling the g++ compiler with proper arguments), or I can create a Managed Make C++ project and Eclipse will manage the Makefile then call make o...

Qt, Mouse skipping, not updating every pixel, mouseMoveEvent()

I working on a simple paint program. It seemed Qt (and KDE) would be a easy way to implement it. I find Qt quite easy to work with, but now I have hit a problem. When I draw something in my program the mouse skips if I move the mouse to fast. like this: It susposed to be like one long string. I'm using mouseMoveEvent() to draw a pixe...

Developing Console Like Apps For Palm OS

Hello, I'm learning C++, but i only develop console apps, because graphical C++ development is so much difficult, then i want to know if i can develop console like apps for Palm OS, what i want is this, compile this code for Palm OS for example: // ClientFille.cpp // Cria um arquivo sequencial. #include <iostream> using std::cerr; usin...