c++

Plain Old Data types with private members?

Is Demo a POD type in C++03? struct Demo { private: int x; int y; }; C++03, §9p4: A POD-struct is an aggregate class that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-defined copy assignment operator and no user-defined destructor. ...

Rounding floating point numbers in C++ to one decimal place

I have a float number in c++ and the number can be in different forms, e.g. 355.5 or 9.9 (this is input from test code). I have a function which is float return_max(angle_set_t *angles) { float val; float max; max= angles->key; while( angles != NULL ) { val= angles->key; if(max<=val)...

What is the sscanf placeholder for uint8_t types?

What is the sscanf placeholder for uint8_t types? I tried %u, but gcc under OS X doesn't like it. ...

Books/Materials for beginning Port Programing C++/Java

I'm used to normal software programing using C++/Java. I'm interested in learning Port programming. Serial port or parallel port programming to control microchips or small electronic circuits. But I don't have any knowledge in electronics, EDIT one simple example is trying to get a grid of LEDs to on to form a text inputed though ...

Xcode PCH issue - Items in PCH Not Included in Source Files

I just created a "C++ Standard Dynamic" library project using Xcode and compiled using LLVM 2.0. I notice that the PCH file contains the line #include <iostream> but the file Test.cp also includes that #include <iostream> statement. The strange thing is that by removing the statement in Test.cp, the build fails with the error Semantic ...

LLVM Compiler 2.0: Warning with "using namespace std;"

In Xcode using LLVM 2.0, when I put the line using namespace std; in my C++ code, I get this warning: Semantic Issue Using directive refers to implicitly-defined namespace 'std' Is there a way to fix this? Why is it giving that warning? ...

opengl recompile display list

If an existing compiled display list is to be recompiled, is it necessary to call glDeleteLists() and glGenLists() first? Or can the display list be recompiled by just calling glNewList() on the existing compiled display list ID? ...

C++ - function overriding or overloading

class A { public: int func1() { cout<<"A's func1"; } } class B:public A { public: int func1() { cout<<"B's func1"; } } in the above code snippet , is the function ' func1()' getting overloaded in class B ? or getting overrided by c...

Convert errno.h error values to Win32 GetLastError() equivalents

I'm writing a layer between a POSIX filesystem, and Windows using Dokan, and need to convert error values of the errno kind (EINVAL, ENOENT, etc.), to the Win32 equivalents you'd receive when calling GetLastError() (such as ERROR_INVALID_PARAMETER). Is there an existing function, library, or reference I can use to perform these conversi...

Error trying to make an wrapper of the STL map container

I'm trying to make a wrapper to the STL map container, in order to add a const method to return the value given the key. In map, operator[] isn't const, and find() requires dereferencing to get the value (map.find()->second). I'm basing some of my "research" off of http://stackoverflow.com/questions/152643/idiomatic-c-for-reading-from-a-...

Downcasting a pointer using a function instead of giant if statement.

I have a vector with pointers of type Vehicle. Vehicle is the base class and there are many derived types like MotorCycle, Car, Plane, etc. Now, in my program there comes a point where I need the derived type while traversing the vector. Each Vehicle class has a GetType() function which returns an int which tells me what the derived type...

How to remove a specific pair from a C++ multimap?

#include <map> ... multimap<char,int> first; first.insert(pair<char,int>('a',10)); first.insert(pair<char,int>('b',15)); first.insert(pair<char,int>('b',20)); first.insert(pair<char,int>('c',25)); Say I now want to remove one of the pairs I have just added to the map. I have examples to remove an entire key entry, which for key 'b'...

Any tool to determine most efficient way of passing data, by reference or by value?

For objects or primitive data with a size equal to or less than size of a pointer the most efficient passing method to a function would definitely be by value but the thing is I want to know would be there any tool capable of determining best method of passing objects of classes or primitive data with a sizes bigger than size of a pointe...

<: cannot begin a template argument list

I get an error <: cannot begin a template argument list on g++ compiler. Code template<typename T> class SomeClass; class Class; SomeClass<::Class>* cls; ...

Do global variables mean faster code?

I read recently, in an article on game programming written in 1996, that using global variables is faster than passing parameters. Was this ever true, and if so, is this still true today? ...

can i use CLucene and the Cue Sheet Parser together?

hello, i'm trying to use clucene-0.9.21b and libcue-1.3.0 in Qt Creator on Kubuntu Lucid. this code is compilable: project.pro SOURCES += main.cpp LIBS += -lcue INCLUDEPATH += /usr/include/libcue-1.3/libcue main.cpp extern "C" { #include <libcue.h> } int main(int argc, char *argv[]) { return 0; } so is this: project.pro SOURC...

working to Hex data using C++

need to help me for working hex string using c++ how to open file binary data hex line by line c++ how to split line using delimiter like 0x3D c++ how to store all lines in vector map except the line founded of search. ex. syntax file binary 32 32 32 32 32 32 30 3D 32 30 31 31 31 30 31 30 32 32 32 32 32 32 31 3D 32 30 31 31 31 30 ...

lvalue-to-rvalue conversion of an array in ISO C

C++ ANSI ISO IEC 14882 2003 Annex C.1 (page 668): Change: The result of a conditional expression, an assignment expression, or a comma expression may bean lvalue Rationale: C + + is an object-oriented language, placing relatively more emphasis on lvalues. For example, functions may return lvalues. Effect on original feature: Change to s...

Why is there a segmentation fault error if I include an array of widgets in Qt?

I'm a little new to object oriented programming, and very new to Qt and GUIs in general. I am now playing with this example in Nokia's Qt tutorial: http://doc.qt.nokia.com/4.1/tutorial-t5.html I tried to extend the code; this is what I have now: #include <QApplication> #include <QFont> #include <QLCDNumber> #include <QPushButton> #incl...

C++ WINAPI: Client area parent dragging with obscuring child tab windows

Attempting to simulate client area based window dragging by returning HTCAPTION under a WM_NCHITTEST (excluding HTCLIENT & appropriate areas) works flawlessly when used with a parent window - however presence of child windows such as tabs placeholder windows, even when set to the extended style WS_EX_TRANSPARENT, cause clicks to fail to ...