c++

ISO C++ forbids declaration of 'Stack" with no type

I have setup the following header file to create a Stack which uses an Array. I get the following at line 7: error: ISO C++ forbids declaration of 'Stack" with no type. I thought the type was the input value. Appreciate your help. Thank you. #ifndef ARRAYSTACKER_H_INCLUDED #define ARRAYSTACKER_H_INCLUDED // ArrayStacker.h: ...

Type problem when including tuple

I'm using Visual Studio 2008 with Feature Pack 1. I have a typedef like this typedef std::tr1::tuple<std::string, std::string, int> tileInfo with a function like this const tileInfo& GetTile( int x, int y ) const. In the implementation file the function has the exact same signature (with the added class name qualifier) and I am gettin...

Call/Return feature of classic C++(C with Classes), what modern languages have it?

Hi, On page 57 of The Design and Evolution of C++, Dr. Stroustrup talks about a feature that was initially part of C with Classes, but it isn't part of modern C++(standard C++). The feature is called call/return. This is an example: class myclass { call() { /* do something before each call to a function. */ } return() { /* do somet...

Converting int array to char*

Is this possible? I wanted to convert this into a char* so I could later retrieve this values. ...

How to Set ActiveX Control name and link on the install window of Internet Explorer?

I created a ActiveX control using ATL, already package it with signature. I want to use it on the webpage, but at the install window the name is MyActiveX.cab with no link. the MyActiveX.cab name can be changed by modifying the html page's tag codebase attribute. but the name is still format like "XXX.cab" with no hyperlink. I find a a...

Cleaning up when exiting an OpenGL app

This might be a dumb question but I've spent some time asking Google and haven't been able to find anything. I have an an OSX OpenGL app I'm trying to modify. When I create the app a whole bunch of initialisation functions are called -- including methods where I can specify my own mouse and keyboard handlers etc. For example: glutInit(...

C# style Action<T>, Func<T,T>, etc in C++0x

C# has generic function types such as Action<T> or Func<T,U,V,...> With the advent of C++0x and the ability to have template typedef's and variadic template parameters, it seems this should be possible. The obvious solution to me would be this: template <typename T> using Action<T> = void (*)(T); however, this does not accommodate f...

c++ line-based unified diff library

Does anyone know of a good c++ library that can provide a line-based unified diff? ...

User input... How to check for ENTER key

I have a section of code where the user enters input from the keyboard. I want to do something when ENTER is pressed. I am checking for '\n' but it's not working. How do you check if the user pressed the ENTER key? if( shuffle == false ){ int i=0; string line; while( i<20){ cout << "Playing: "; songs[i]->prin...

C++ function overloading and dynamic binding compile problem

Possible Duplicates: C++ method only visible when object cast to base class?! Why does an overridden function in the derived class hide other overloads of the base class? #include <iostream> using namespace std; class A { public: virtual void foo(void) const { cout << "A::foo(void)" << endl; } virtual void foo(int ...

C triple dereferencing

Possible Duplicate: Uses for multiple levels of pointer dereferences? I have used functions with doubly dereferenced pointers (**var) to return values. However, I was recently asked a question to figure out a use-case where a triple dereferencing (***var) may be needed. I couldn't think of any practical scenario. Does anyone h...

How to write a simple Lexer/Parser with antlr 2.7?

Hello, I have a complex grammar (in antlr 2.7) which I need to extend. Having never used antlr before, I wanted to write a very simple Lexer and Parser first. I found a very good explanation for antlr3 and tried to adapt it: header{ #include <iostream> using namespace std; } options { language="Cpp"; } class P2 extends...

Copy constructor demo (crashing...)

Here is the program... class CopyCon { public: char *name; CopyCon() { name = new char; } CopyCon(const CopyCon &objCopyCon) { name = new char; _tcscpy(name,objCopyCon.name); } ~CopyCon() { if( name != NULL ) { delete name; name = NULL; } } }; int main() { CopyCon objCopyCon1; objCop...

Better name for CHAR_BIT?

I was just checking an answer and realized that CHAR_BIT isn't defined by headers as I'd expect, not even by #include <bitset>, on newer GCC. Do I really have to #include <climits> just to get the "functionality" of CHAR_BIT? ...

C++ const qualifier

I have a Point2D class as follows: class Point2D{ int x; int y; public: Point2D(int inX, int inY){ x = inX; y = inY; }; int getX(){return x;}; int getY(){return y;}; }; Now I have defined a class Line as: class Line { Point2D p1,p2; public: LineVector(c...

C++ File I/O problem

I am trying to open a file which normally has content, for the purpose of testing i will like to initialize the program without the files being available/existing so then the program should create empty ones, but am having issues implementing it. This is my code originally void loadFiles() { fstream city; city.open("city.txt", ios::...

Porting Symbian C++ to Android NDK

I've been given some Symbian C++ code to port over for use with the Android NDK. The code has lots of Symbian specific code in it and I have very little experience of C++ so its not going very well. The main thing that is slowing me down is trying to figure out the alternatives to use in normal C++ for the Symbian specific code. At th...

what is the best approach to parse xml data to make it as generic as possible in Qt

Hello all. I'm trying to find a good and effective way to parse an XML data structure that different API calls are returning. The problem is that each time I need different data and each time I'm getting a different XML structure. Which is better: to use the SAX approach or The DOM approach? Does QT 4.6 recommend or work better with o...

Typedef C++, couldn't resolve its meaning

I read this typedef line in a C++ book, but I couldn't resolve its meaning: typedef Shape* (*CreateShapeCallBack)(); Now, CreateShapeCallBack stands for what, any idea? Thanks. ...

signal qt from a non-qt thread, QueuedConnection

hello, I am signaling my Qt GUI thread from a boost::thread, and I am using a Qt::QueuedConnection, connect(src, SIGNAL(signal-signature), dest, SLOT(slot-signature), Qt::QueuedConnection); and still, when I emit the signal my slot does not get called. edit: I found the problem, it seems that I was connecting the signal later then ...