c++

What is the best LALR parser generator for C++ that can generate meaningful error messages

I am looking for the best solution for a LALR parser generator for C++ that will allow me to generate really good error messages. I really hate the syntax errors that MySQL generates and I want to take the parser in it and replace it with a "lint" checker that will tell me more than just ERROR 1064 (42000): You have an error in your S...

Using STL containers for multiple keys

I came across one requirement where the record is stored as Name : Employee_Id : Address where Name and Employee_Id are supposed to be keys that is, search function is to be provided on both Name and Employee Id. I can think of using a map to store this structure std::map< std:pair<std::string,std::string> , std::string > // ...

how to bias a random number generator

i am using the random number generator provided with stl c++. how do we bias it so that it produces smaller random numbers with a greater probability than larger random numbers. ...

Reopening a closed Piped read file descriptor?

Hi all, I have used pipes to facilitate interprocess communication. They work just fine. But in my scenario I want to close and reopen the read end of the file descriptor fd[0]. Does anyone know how to do that? ...

Small question concerning redefining member functions

I'm trying to redefine two member functions from their parent's definition.I don't know if I have it right or not, but something in my code has errors attached and I can't find out what. some of the header: class Account { public: Account(double); void creditBalance(double); void debitBalance(double); double getBalance() c...

C++ Duplicate Symbol error when defining static class variable in XCode

I have a static class member incremented in the constructor. As per the rules, it is declared in the class and defined outside. This should be totally legal. Any ideas why I'm getting a duplicate symbol error? class Player { private: static int numPlayers; public: Player() { numPlayers++; } }; int Player::numPlayers =...

Shall I place try...catch block in destructor, if I know my function won't throw exception.

I know destructor shouldn't not throw exception. http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.13 I have the following code : ~a() { cleanup(); } // I do not expect exception being thrown in this function. // If exception really happen, I know that it is something not recoverable. void a::cleaup() { delete p; } In...

Connecting and Fetching a record form sequel server 2005.

I have a windows application in visual C++. I am not using MFC, in this application I have connect to SQL server 2005 and fetch records form a database file. Can any one guide me how this can done. Thanks in advance. ...

How can I simplify my C++ code to reverse characters?

Hello I have this program which reverses letters I enter. I'm using iostream. Can I do it another way and replace iostream and cin.getline with cin >> X? My code: //Header Files #include<iostream> #include<string> using namespace std; //Recursive Function definition which is taking a reference //type of input stream parameter. ...

performance of table access

Hi, we are having an application which is completely written in C. for table accessing inside the code like fetching some values from atable we use pro*C and for increasing the performance of the application we also preload some tables for fetching the data.we take some input fields and fetch the output fields from the table in general....

Vectors, "virtual", Segmentation Fault on function call

I'm getting a Segmentation Fault when trying to call a function that is within a object that is part of a vector of "Shape" Pointers My problem is in this function:: Point findIntersection(Point p, Point vecDir, int *status) { Point noPt; for (int i = 0; i < shapes.size(); i++) { Point temp; ...

How to catch this error? [C++]

Hi, I'm trying to catch dividing by zero attempt: int _tmain(int argc, _TCHAR* argv[]) { int a = 5; try { int b = a / 0; } catch(const exception& e) { cerr << e.what(); } catch(...) { cerr << "Unknown error."; } cin.get(); return 0; } and basically it doesn't work. Any advice why? Thank you. P.S. Any chance that in the future code...

Segmentation fault when instantiating object from particular library

I have an C++ application (heavily shortened down, shown below); #include <iostream> #include "MyClass.h" void foobar() { MyClass a; } int main(int argc, char** argv) { std::cout << "Hello world!\n"; return 0; } Where "MyClass" is defined in a statically linked library (.a). However, this application Segfaults the instant its ...

Component Object Model via C++(maybe VS)

Hello, I was searching through google about Microsoft Component Object Model. Found only few normal articles and only 1 step by step example, which doesn't work. Is there any links/references/books/tutorials you know how to build simple COM component via VS C++? Any answer or help would be appreciated! ...

Export every frame as image from a Movie-File (QuickTime-API)

I want to open an existing Movie-File and export every frame of this file to an image like JPEG or TIFF. I got so far until now: int main(int argc, char* argv[]) { char filename[255]; // Filename to ping. OSErr e; // Error return. FSSpec filespec; // QT file specification short filemovie; // QT movie h...

Using C++, how do I read a string of a specific length, from a non-binary file?

The cplusplus.com example for reading text files shows that a line can be read using the getline function. However, I don't want to get an entire line; I want to get only a certain number of characters. How can this be done in a way that preserves character encoding? I need a function that does something like this: ifstream fileStream;...

A bot to Access data on grid of a windows application (like a human)

I'm so desperate to use a vpn application. In this app there are some limitations that I've found no solutions for them for example multiple users can connect to the vpn server using one username at the same time. In order to stop that I have to look at the 'connected vpn clients' and see if a username exists more than once and then disc...

Compiling a gnu program without sse3

I'm compiling an app for a device where the architecture does not support sse beyond sse2, and was wondering is it possible to disable compiling with sse3 instructions from GNU autoconf generated configure scripts? I know you can turn it off in gcc/g++ with mno-sse3 option, but it would be nice if I could turn it off at the configuration...

catching exception objects by reference, temporaries, lifetime issues

Consider the following code: #include <iostream> #include <stdexcept> void foo() { throw std::runtime_error("How long do I live?"); } int main() { try { foo(); } catch (std::runtime_error& e) { std::cout << e.what() << std::endl; } } Why can I catch the exception by reference, isn't std::r...

Problem with operator ==

I am facing some problem with use of operator == in the following c++ program. #include < iostream> using namespace std; class A { public: A(char *b) { a = b; } A(A &c) { a = c.a; } bool operator ==(A &other) { return strcmp(a, other...