c++

Markov C++ read from file perfomance

Hi all, I have my 2nd assignment for C++ class which includes Markov chains, The assignment is simple but I'm not able to figure out what is the best implementation when reading chars from files I have a file around 300k, one of the rules for the assignment is to use Map and Vector classes in Map (key is only string) and values will be ...

Forcing 32-bit architecture via configure

Hi. What is the best way to force a configure script to build a 32-bit code? I have a 64-bit machine, and trying to build a 32-bit code. Tried setting the --build type with several options, but this just doesn't work. Thanks! ...

Printing an uninitialized bool using cout (C++)

I have a class with a bool data member that is not initialized by the constructor. If I do cout << x.myBoolDataMember; where x is an object of this class in which the bool has not been initialized, I sometimes get a random number rather than 0 or 1. (I'm using gcc.) Is this behavior compliant with the Standard? ...

Long Integer and Float

If a Long Integer and a float both take 4 bytes to store in memory then why are their ranges different? ...

C++ equivalent of .net Stream?

What is the base class of all the streams in C++? Also what is the equivalent of MemoryStream in C++? ...

How to implement you own custom DirectShow renderer?

How to implement you own custom DirectShow renderer that could work a-la or instead of SampleGrabber? ...

So you think you know the priority of operators in c++?

I just ran into a piece of code that not only compiles, but gives the expected result (where x is an integer value): int y = (int)(0.5 * x * x + + + 0.6 * x + 1.2); It took me a while to figure out what happens and I must say it was an interesting operator problem. Without compiling the program, what are the results of the following o...

why we should not override the non virtual member functions?

Possible Duplicate: redefine a non-virtual function in C++ the rule of the thumb is "you should not override the non virtual member functions of the base class" now if i override the the non virtual member functions of the base class what are the dangers please explain with examples. ...

C++ multithreading problem - is mutex the only way?

I have a counter variable which will be accessed by multiple threads which will increment/decrement it. It should not be updated by multiple threads at the same time. I know that you can create a mutex object which has to be obtained before the variable in question can be changed. A critical section in this case is not appropriate becau...

Are there open source audio stream clients or frameworks?

I'm looking for how to play back audio streams in these formats: MP3 Ogg / Vorbis WMA over MMS/ASF AAC / AAC+ target is the mac and iPhone. Maybe there is an open source library that I could look at, to understand how it works, and then port it to the cocoa frameworks somehow. ...

Is it safe to allocate memory for buffers on external dll and use it on main application?

As in topic.. I've found something like this in one application. In main C application we have declaration: void* buff = NULL; and later there is a call: ReadData(&buff); SaveToFile(buff); SaveToFile() is a C function from main function. ReadData(void* * ) is a C++ function from external dll. In this function memory for buffer is...

Boost::bind a method with boost::function parameter

I would like to provide an extra boost::function to a async_write. I want the connections own HandleWrite function to be called first and then call the provided boost::function. Member method of Connection that binds to asio async_write void Connection::HandleWrite( const boost::system::error_code& e, boost::function<void (con...

functions memory management C++

hi everyone, i have a little bit lame question, but it's time i have this finally clear. consider regular function with some parameters and a return type. My questions are: are there always made some copies of parameters? i mean even if the function expects reference or pointer as parameter, there are actually new references/pointers ...

Matlab repmat function equivalent in c++

Is there an equivalent in c++(in any API/library) for Matlab repmat function ? ...

Sparse voxel representation of point cloud data

Is there a c/c++ implementation of sparse voxel representation for any 3D point cloud dataset? ...

How to overload unary minus operator in C++?

Hello, I'm implementing vector class and I need to get an opposite of some vector. Is it possible to define this method using operator overloading? Here's what I mean: Vector2f vector1 = -vector2; Here's what I want this operator to accomplish: Vector2f& oppositeVector(const Vector2f &_vector) { x = -_vector.getX(); y = -_vector....

Two '==' equality operators in same 'if' condition are not working as intended.

I am trying to establish equality of three equal variables, but the following code is not printing the obvious true answer which it should print. Can someone explain, how the compiler is parsing the given if condition internally? #include<stdio.h> int main() { int i = 123, j = 123, k = 123; if ( i == j == k) ...

Simplest way to get a PTY in Linux C++

Hello, all. I am programming something that needs an interface to Bash. At first I thought I could just use popen or QProcess. ( I'm using QT C++ ) They work fine but I can't get them to run Bash in a tty, which you need if you are going to use anything like sudo, which requires a tty/pty to accept a password. I found some things like ...

code anaylsis node missing from Visual studio 2008

I want to have a look at the VS code analysis tools. This msdn page suggests: Expand the Configuration Properties node. Expand the Code Analysis node. Unfortnately when I expand the configuration properties node I only have the options: General, Debugging, c/C++, Linker, Manifest tool, XML Document Generator, Browse Information, Build...

How to handle all errors, including internal C library errors, uniformly

I wanted to handle all internal errors gracefully, without program termination. As discussed here, using _set_se_translator catches divide-by-zero errors. But it does not catch, for example, C runtime library error -1073740777 (0xc0000417), which can be caused by format strings for printf which have the percent sign where they shoul...