c++

How do i use C++ with Flex?

How can i outsource performance critical stuff to C++. Is there any example ? ...

Standard convention for using "std"

Exact Duplicate: Do you prefer explicit namespaces or ‘using’ in C++? Which of these is a preferred convention for using any namespace? using namespace std; or using std::cin; using std::cout; or calling the function as and when required in the code? std::cout<<"Hello World!"<<std::endl; ...

How much time would it take to write a C++ compiler using flex/yacc?

How much time would it take to write a C++ compiler using lex/yacc? Where can I get started with it? ...

Can I use partial template specialization for a (non-member) function?

I'm trying to use partial template specialization on a (non-member) function, and I'm tripping up on the syntax. I've searched StackOverflow for other partial template specialization questions, but those deal with partial specialization of a class or member function template. For a starting point, I have: struct RGBA { RGBA(uint8 ...

How to implement reference counting for library class whose implementation cant be changed ?

I come to know that when many objects shares same data and creation and desturction of objects are expensive then one can go for reference counting . Can anybody give input about how to achieve it for the library class which cant be changed ?. ...

Why not Turbo C++?

I am an Engineering Student from University Of Mumbai::RAIT. I am learning C++ from "C++ Primer" by Stanley Lipman and using Visual C++ 2008 as IDE. But, my institute and most of the institutes in my University prefer to use Turbo C++(Version 3.0) by Borland International. What arguments can I put against the use of Turbo C++ in my insti...

unary pointer increment in function call vs increment before/after function call

I am trying to understand a code, here is fragment which is causing confusion: typedef map<int, Person, less<int> > people_map; people_map people; . . . cout << "Erasing people of age 100" << endl; for (people_map::iterator j = people.begin(); j != people.end();) { if (j->second.GetAge() == 100) { peopl...

Destructors called upon program termination

When an object is created in your main() function, is its destructor called upon program termination? I would assume so since main() still has a scope( the entire program ), but I just wanted to make sure. ...

Can I use Qt as C++ Library without using its UI framework

Does it make sense to use Qt for increasing the productivity in an MFC app, without actually using the Qt user interface system? I am currently looking or a good productivity library for my MFC based application, with useful container classes, string algorithmus, threading classes, I/O classes and so on. The Qt API is very nice in my o...

Get ID from MIDI devices in C++

Hi all I'm a musician and a programmer and would like to create my own program to make music. I'll start with a console application in C++ before I make a GUI. I'm quiet new to C/C++ and know how to make a basic console application and have read about the Win32 API. I was looking into MSDN for multimedia in Win32 applications and I fo...

C or C++ - dynamically growing/shrinking disk backed shared memory

I have several fastcgi processes that are supposed to share data. The data is bound to a session (a unique session id string) and should be able to survive a server reboot. Depending on the number of sessions, the shared data might be too big to fit into main memory. Ideally, in the case when the shared data exceeds a certain treshold, t...

Displaying 3D models using C++

I am currently designing an application in C++. Part of this application would be displaying changing 3D objects. I have designed several bits of these 3D objects in Blender And also am aware of other programs with which to do this (Maya, etc.) However, I am unsure how to use C++ To display these objects, much less manipulate them in...

HZ variable not defined

Hey, I'm trying to compile someone's code right now and the person is using a variable HZ (which I think stands for Hertz for the hertz of the cpu) but the compiler is complaining that the variable is not defined. My guess is that the person didn't include the correct header file. So does anyone know which header file, HZ is defined in...

How can I write my own 'filesystem' within Windows?

I've recalled using little 'filesystems' before that basically provided an interface to something else. For example, I believe there was a GMail filesystem that created an entry in My Computer and could be used like any other drive on your local computer. How can I go about implementing something like this in C++? Thank you! ...

Xcode STL C++ Debug compile error

I have some file writing code that works as expected, but prints an error on Debug mode, no output errors in Release. Code: #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; int main (int argc, char * const argv[]) { string cppfilename; std::cout << "Please enter the filename to...

Is C++ static member variable initialization thread-safe?

Hi! According to following resources, in C++(Specially Visual C++) scoped static variable initialization isn't thread safe. But, global static variables are safe. http://stackoverflow.com/questions/1052168/thread-safe-static-variables-without-mutexing http://blogs.msdn.com/oldnewthing/archive/2004/03/08/85901.aspx So, is following co...

std::vector reserve method fails to allocate enough memory

Hi, I have a buffer class in my C++ application as follows: class Buffer { public: Buffer(size_t res): _rpos(0), _wpos(0) { _storage.reserve(res); } protected: size_t _rpos, _wpos; std::vector<uint8> _storage; } Sometimes using the constructor fails because its unable to allocate the required memory ...

std::map and 'fat' value objects

Hello! What's better from a performance point of view std::map<uint32_t, MyObject> or std::map<uint32_t. MyObject*> if MyObject is 'fat' (that is operator= rather expensive) and I have to insert/update/delete a lot ? ...

how to indicate server when a client is interrupted ?

hi, how to inform the server that is a client is interrupted, and close the socket? Thanks! ...

Find Even/Odd number without using mathematical/bitwise operator

Hi, I was recently asked to write a program, that determines whether a number is even or odd without using any mathematical/bitwise operator! Any ideas? Thanks! ...