Top.Mail.Ru
The C++ Community's Journal -- Day
? ?
The C++ Community's Journal -- Day [entries|friends|calendar]
The C++ Community

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

Constructor arguments for an array of objects [10 Sep 2006|08:42pm]
Hi, everyone. Thanks for being so helpful in the past. I haven't posted here in a while, but I think I have a pretty good question:

I have a class called DumbWav, which loads an audio file into memory so I can monkey around with the data and then re-save it. (In case you're wondering, yes, there was originally a SmartWav, but that converts everything to a bunch of fourier-transformed windows, which is can be extremely useful, but not for all purposes.)

DumbWav's constructor takes a single argument which is the name of a file to open. If you need to know, it's the old C-style character array, which I really have no reason for using other than habit.

What I'd like to do is have an array of DumbWavs, each loading a different audio file. Problem is, I don't know of any way to declare an array that passes a different argument to each constructor.

What I know I could do, is to remove the loading process from the constructor and just make a separate DumbWav::read() function, which I could call in a loop after declaring the array. But I'd like to avoid that if it's an unnecessary step.

I'd like to be able to do something like this:

DumbWav w[3]{("sound1.wav")("sound2.wav")("sound3.wav")};

I'm sure that's syntactically wrong, but is there an equivalent? Not the end of the world if there isn't, but thanks in advance for any tips.
15 comments|post comment

navigation
[ viewing | September 10th, 2006 ]
[ go | previous day|next day ]
Image