c++

C++ Error C2040?

Error Message: What does this mean? And how do I fix it? error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]' Code: #include <iostream> #include <cmath> using namespace std; int round(double number); //Assumes number >=0. //Returns number rounded to the nearest integer. int main() { double doubleVal...

Role of C,C++,python,perl in Web development

Please bear with me experts i'm a newbie in web dev. With html,css can take care of webpages.. javascript,ajax for some dynamic content.. php for server side scripting,accessing databases,sending emails,doing all other stuf... What role do these programming languages play? Can they do any other important task which cannot be done by PH...

How to teach Object Oriented Programming - Any idea where to start ?

I'm teaching C++ for about 2 years in high schools, computer training institutes and etc. After teaching basics about variables, arrays, structures, functions, I always start object oriented examples part with traditional examples, like this one: class Person { public: Person(); ~Person(); char* getFirstName(); //we can use std::st...

Pure Virtual Function called error.

I find this strange. In the ctor of Sample_Base, I call bar() which internally calls fun() which is a pure virtual function. I get the error "pure virtual function" called. Which is fine. Now, if I call fun() directly from Sample_Base's ctor, I don't get that error. I tried it on VC++ 2010 Beta 2 and on g++ 4.4.1 on Ubuntu 9.10. I agree ...

arduino web client class not working

I am trying to use arduino client class to fetch an html page from internet (Example from arduino library itself), but it's not working (Connection is not getting established). It's failing at: client.connect(); I have tried both Ethernet and Ethernet2 libraries. My arduino development platform version is 0017 , OS is win XP. Follo...

Using dynamic allocations in a mission-critical / life-critical software

Is it safe to use dynamic allocations in a mission-critical / life-critical system, or should it be avoided? ...

Languages with direct C compatibilty

Apart from C++, which non-toy languages have direct or easy-to-use compatibility to C? As in "I can take a C library out there, and compile my code against it without having to find, write, or configure some kind of wrapper." I know that lots of languages have compatibility with C through some form of external call or binding (I've be...

Algorithm for finding the number which appears the most in a row - C++

I need a help in making an algorithm for solving one problem: There is a row with numbers which appear different times in the row, and i need to find the number that appears the most and how many times it's in the row, ex: 1-1-5-1-3-7-2-1-8-9-1-2 That would be 1 and it appears 5 times. The algorithm should be fast (that's my problem)...

Is there a C++ IDE which handles templates well?

Every IDE I've tried fails to provide code-completion when something template-related is used. For example, boost::shared_ptr<Object> ptr; ptr->[cursor is here] Is there IDE that can provide code completion in this case? ...

c++ what in-memory compression library?

Hi! I already googled for in-memory compression and found quite a few libraries that offert this functionality. the zlib seems to be widely used - but it also seems to be quite old. I'm asking here whether there are newer, better alternatives. The data i want to compress in-memory are memorypools with size of a few megabytes (2-16 MB) ...

How to make plugable factory work with lua ?

class data is like this: struct Base_data { public: Base_data(){ protocolname = "Base"; } string protocolname; }; class HttpData : public Base_data { public: HttpData(){ protocolname = "Http"; } }; class Professor: class Base_Professor { public: void Process(Base_data if(it == ListProf...

Performance of ostream_iterator for writing numeric data to a file?

I've got various std::vector instances with numeric data in them, primarily int16_t, int32_t, etc. I'd like to dump this data to a file in as fast a manner as possible. If I use an ostream_iterator, will it write the entire block of memory in a single operation, or will it iterate over the elements of the vector, issuing a write opera...

C++/SDL 'void*' is not a point-to-object type

Hello there, I'm new on C++ and I'm trying to make some testing with C++ and SDL and in SDL we have a function: SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); which I can pass a callback for the timer created. But apparently it converts my instance this to *void so I can't retrieve it again on...

Need a calc example for ANTLR3

Hi/lo. I've succesfully installed ANTLR3 on my Windows and bound it to Visual Studio, but... Could anybody show me a working example of calculator in C++/ANTLR? The same as from distrib, which is written in Java. I have a trouble making it. I use std::map<std::string, double> for nametable, but one cannot load C++ headers from @header,...

How to do precise mouse event handling in QGraphicsScene when ItemClipsChildrenToShape is enabled?

I have a QGraphicsItem that clips its child items (I enabled its ItemClipsChildrenToShape flag). I noticed that clipping makes assigning the mouse event to the children items imprecise: instead of the precise shape of the items their bounding rectangles are used for detecting which item is located at the specific position so the children...

Good Poco C++ tutorial

Hi. Does anyone know of a good Poco C++ tutorial, which provides a good introduction to first usage of this framework? I seen the examples and reference, but need something that will get me quickly started. Thanks. ...

boost::asio cleanly disconnecting

Sometimes boost::asio seems to disconnect before I want it to, i.e. before the server properly handles the disconnect. I'm not sure how this is possible because the client seems to think its fully sent the message, yet when the server emits the error its not even read the message header... During testing this only happens maybe 1 in 5 ti...

Box2D body position always (0,1) on spawn

I'm creating a b2BodyDef with the position set to (10,10). Then I run world->CreateBody(&shDef); but the b2Body is created at position (0,1). How can I fix the body creation so that it spawns at the desired location? I know the body is in the wrong place because: A. The rendering system isn't rendering it in the right place B. Print...

Cygwin port not working => exits immediately on launch

Hi, I am trying to port a C++ program from Linux to Windows using cygwin. I have it building and linking fine now, but when I launch the program, it exits immediately with an error. When I try it in gdb, I get the following 'unknown target exception' result: $ gdb ../../bin/ARCH.cygwin/release/myApp GNU gdb 6.8.0.20080328-cvs (cygwin...

Complete C++ "from scratch" frameworks

What C++ frameworks provide a complete skeleton, in the fashion of Ruby on Rails? I think Poco C++ does it, are there other options? ...