I am new to boost and trying to write some simple programs to understand it. Here in the following piece of code I am trying to fill an array with random numbers. Here is my code:
using namespace boost::lambda;
srand(time(NULL));
boost::array<int,100> a;
std::for_each(a.begin(), a.end(), _1=rand());
But it looks like r...
I need a library for MS VC6 which encodes sampled data which is in the form of a float array, to an audio file format preferably wav
Also is there a library that can encode the samples into pcm form and play it directly through the sound card without saving a wav file first??
...
I want to make a very simple c++ instant messenger for lan networks and internet (direct IP connect). I know little about sockets. I searched the internet, but nothing really helped. I would someone to suggest a howto/tutorial/guide. I just want to send and receive messages (in a console window, I'll create the gui later). I want it to b...
I am having problems with a fairly complex code. I wasn't able to produce a short snippet that reproduces the error, so I'll try to explain the problem in words.
The code crashes randomly with the error
*** glibc detected *** gravtree: corrupted double-linked list: 0x000000001aa0fc50 ***
Debugging showed that it comes from the line w...
A class has overloaded operators new and delete. new is public, delete is private.
When constructing an instance of this class, I get the following error:
pFoo = new Foo(bar)
example.cpp(1): error C2248: 'Foo:operator delete': cannot access private member declared in class 'Foo'
But there's no call to delete here, so what is going o...
I was wondering if there is some compiler parameter, preferably in gcc (g++) which treats the lack of try/catch blocks as errors. This is the standard behavior in java and I was alway fond of it.
...
What is the best way to replace characters in a string?
Specifically:
"This,Is A|Test" ----> "This_Is_A_Test"
I want to replace all commas, spaces, and "|" with underscores.
(I have access to Boost.)
...
Is it possible in C++ to have a member function that is both static and virtual? Apperantly, there isn't a straight-forward way to do it (static virtual member(); is a complie error), but at least a way to acheive the same effect?
I.E:
struct Object
{
struct TypeInformation;
static virtual const TypeInformation &GetTypeInfor...
I've been able to set local hotkeys like this
RegisterHotKey(hwndDlg, 100, MOD_ALT | MOD_CONTROL, 'S');
how can I set the hotkey to be global?( I want it to be there even when my window is hidden)
...
I'm lead to believe that function pointers are going to be needed to assign functions to the images that will be used as buttons somehow, but I can't find any decent resources on this.
How can you set up a button menu in C++? For example, having buttons for save, load, exit, new.
edit: I am not worried about portability for this exa...
I'm trying to sort a listview when the user clicks on the column header.
I am catching the LVN_COLUMNCLICK notification like so:
case LVN_COLUMNCLICK:
{
NMLISTVIEW* pListView = (NMLISTVIEW*)lParam;
BOOL test = ListView_SortItems ( m_hDuplicateObjectsList, ListViewCompareProc, pListView->iSubItem );
break;
}
...
Hi,
I have a cross platform C++ application that is broken into several shared libraries and loads additional functionality from plugin shared libraries. The plugin libraries are supposed to be self contained and function by themselves, without knowledge of or dependency on the calling application.
One of the plugins contains copied...
I'm just starting to learn C++, and I was wondering if anyone could suggest a few small projects that I could work on that'll help me learn more about what I'm doing.
So far the most complex thing I've written is a program that runs when I first log in to my computer (yay auto-run) and writes the date/time to a .txt file. So I'm looking...
I thought I dug most of what I need out of the header files, but I keep crashing out.
Here is the declare I tried using, but I don't think it's just an issue of the declare. I think I'm actually using it wrong.
Private Declare Function GetLocaleInfoEx Lib "kernel32" ( _
ByVal lpLocaleName As Long, _
ByVal LCType As Long, _
ByRef lpLCDat...
Hi all,
Should be a newbie question...
I have existing code in an existing class, A, that I want to extend in order to override an existing method, A::f().
So now I want to create class B to override f(), since I don't want to just change A::f() because other code depends on it.
To do this, I need to change A::f() to a virtual method...
In the book 'C++ In A Nutshell', there is the following example code
std::vector<int> data
...
std::erase(std::remove(data.begin(), data.end(), 42),
data.end());
I thought that 'erase' was a member function, so shouldn't that be 'data.erase' rather than 'std::erase'?
Is there some way the c++ compiler can tell what member you wanted...
What new kind of functionalities (for debugging or not) do you find helpful by overriding the new operator?
...
Using Visual Studio with Microsoft's C++ compiler, we have several source files which use the Microsoft-specific '#import' directive to import a type library. For instance:
#import my_type_lib.tlb
I'd like to remove the #import from the source code, and replace it with a command line step to be executed via GNU Make. The necessary i...
If I have a container (vector, list, etc) where each element is a std::pair, is there an easy way to iterate over each element of each pair?
i.e.
std::vector<std::pair<int,int> > a;
a.push_back(std::pair(1,3));
a.push_back(std::pair(2,3));
a.push_back(std::pair(4,2));
a.push_back(std::pair(5,2));
a.push_back(std::pair(1,5));
and the...
Hi there.
Actually, I have a design question here. Its very simple but the point is:
I have one C++ class that has a STL vector declared as a private member. But the clients of that class need to iterate over this vector.
In C# we have a very handy statement, the Yield, that in cases like that, you write a function returning an IEnu...