[Discuss] SemiOT - Question for the C++ gurus
Adam Parkin
pzelnip at gmail.com
Mon Mar 5 15:25:53 PST 2007
John Vetterli wrote:
> If you don't like the static dummy array that pw suggested, you can try
> this:
>
> class SomeClass
> {
> public:
> SomeClass (std::vector<std::string> vecIn = std::vector<std::string>())
> : privVec (vecIn) { };
Sweet, that's *exactly* what I was looking for.
> I would even suggest declaring the parameter to be a reference type to
> avoid an extra copy:
Yeah, I was actually passing by reference in my actual code, just forgot
it in the e-mail message (I didn't copy & paste as I was writing the
e-mail on one machine and coding on another).
>> SomeClass Foo (); // Foo.privVec initialized with empty vector
>
> No, this declares a function named "Foo" that takes no parameters and
> returns a "SomeClass" object. You want:
Nitpicker. =8-p (again, this was a case of not syntax checking code
written for an e-mail before sending). Next time I'll write:
// Foo->privVec is empty vector
SomeClass * Foo = new SomeClass();
// Bar->privVec is copy of someVec
SomeClass * Bar = new SomeClass(someVec);
=;->
At any rate, thanks for the tips....
--
--
Adam Parkin
E-mail: pzelnip at gmail.com
Blog: http://www.gamertagblog.com/blog/333
----------------------
You don't stop laughing because you grow old; you grow old because you
stop laughing.
More information about the Discuss
mailing list