c++

Qt ISO C++ forbids declaration without type - header file is included?

Hello, I'm receiving the forbids declaration without type error in a Qt application I'm working on. The problem is that I have included the header file which declares the class. It should be defined as a type as far as I can tell. I tried forward declaration as well, but I'd like to use the methods of the class in this file and so I...

embedded programming in C

Hi, I am a newbie as far as it comes to embedded systems programming. I have to write lots of simple C or C++ programs like atoi, itoa, oct_to_dec, etc., which would have been easy to write in normal C. But my hardware unit does not have the usual header functions and hence I cannot use standard library functions. :( Could someone hel...

Assignment and comparison

Looking at the code: int i = 5; if (i = 0) { printf ("Got here\n"); } What does the C standard have to say about what will get printed? Or in more general terms does the assignment happen first or the comparison? ...

potential bug openGL

I am attempting to tile an image on the screen using menus. My menu works-tiling in the appropriate way-properly until I move my mouse then the tiling design disappears? #include <GL/glut.h> #include <fstream> #include <cstdlib> #include "TUGL.h" #include <glui.h> //Global variables class GLintPoint { public: GLint x; ...

Qt 'Rectangle' is not a type - when rectangle is declared as a class

Hi, Im having a problem of my Rectangle class not being seen as a type. I've included the proper header, and so I am confused. shapes.h #ifndef SHAPES_H #define SHAPES_H #include "Colors.h" #include <QPoint> #include "glwidget.h" //class GLWidget; class Shape { public: virtual void draw(); }; class Rectangle : Shape...

Large scale usage of Meyer's advice to prefer Non-member,non-friend functions?

For some time I've been designing my class interfaces to be minimal, preferring namespace-wrapped non-member functions over member functions. Essentially following Scott Meyer's advice in the article How Non-Member Functions Improve Encapsulation. I've been doing this with good effect in a few small scale projects, but I'm wondering...

Pointer Question

Hi, Can you please explain to me what is happening here? char data[128]; // Create char array of size 128. long * ptr; // Create a pointer. ptr = (long *) data; // ?? Mainly, what does the (long *) mean? Does it mean that the data is of type char, and I am casting the reference to data as a reference to a long? Thank you. ...

What is a good book to learn about the compilation/build process?

Possible Duplicate: The Definitive C++ Book Guide and List I have a basic knowledge of C++, but I am not a Computer Science major. I was looking for a good book for beginners that explains what happens to the code once I click compile or build. Specifically I am trying to make sense of terms like objects, building, compiling,...

Basic signal handling in C++

This is a pretty basic scenario but I'm not finding too many helpful resources. I have a C++ program running in Linux that does file processing. Reads lines, does various transformations, writes data into a database. There's certain variables (stored in the database) that affect the processing which I'm currently reading at every iterati...

Plugin System without rebuilding for each OS?

I'm making a game that will allow content development and I'd like it to be sort of a DLL based system. But, my game works for Linux (X86 arch) , Mac OSX and 32 bit Windows. Is there a way I could allow content developers to compile only one thing and have it work based on the platform? I fear it might get confusing if there are 3 versio...

Accessing MySQL through C++

I want to run queries on my MySQL server through a C++ program that will be released to the public for free, but not under the GPL or any other open-source license. My first question is if I can use the MySQL Connector/C++ library in my application. If not, then what alternatives are there for me to use? ...

Calling map::find with a const argument

I have an object: map<A*, string> collection; I would like to call the map::find function, but the value I have for the key is const, like in the following code, which does not compile: const A* a = whatever(); collection.find(a); The following code works and performs the equivalent of the find operation: const A* a = whatever(); ...

Why should I have an enumeration declared with a typedef in C++?

I had code that looked like this: enum EEventID { eEvent1, eEvent2, ... eEventN }; And that got reviewed and changed to typedef enum { eEvent1, eEvent2, ... eEventN } EEventID; What is the difference between the two? Why make the change? When I looked at this question, the only mention of typedefs got downvoted. ...

C++ and java frameworks for augmented reality

anyone could help me about this one? I think it would be nice to be my thesis on my next year of college. I would like to develop a desktop application not a mobile application. I want to develop it in a linux platform. ...

How to Pass a std::string variable into a function

Hi I have a C++ Method that takes one variable the method signature is like this. DLL returnObject** getObject( const std::string folder = "" ); I tried passing in const std::string myString = "something"; but i get the following error No matching function call to ... getObject( std::string&); I have a couple questions here. 1. ...

normalized viewport

How do you write a function for a normalized viewport using openGL ...

Programmatically Altering Images

I'd like to alter images programmatically. Specifically for the iPhone, but, general answers could help. For example, how could I, programmatically, add filters effects, such as those available in Photoshop. Clearly it is possible as exemplified by apps such as Fat Booth. What is the starting point for this? Load an image as NSData and ...

Can I get polymorphic behavior without using virtual functions?

Because of my device I can't use virtual functions. Suppose I have: class Base { void doSomething() { } }; class Derived : public Base { void doSomething() { } }; // in any place { Base *obj = new Derived; obj->doSomething(); } the obj->doSomething() will call just the Base::doSomething() Is there a way with Base *o...

Implementing communication timeout

Hi, I'm implementing a class that talks to a motor controller over a USB device. I have everything working except for a way to indicate whether a parameter fetched over the comm link is "fresh" or not. What I have so far: class MyCommClass { public: bool getSpeed( double *speed ); private: void rxThread(); struct MsgBase { /*...

C++ equivalent to the Python len() function?

I have an integer and need to find out how many digits are in it. ...