|
![](/i/fill.gif) |
Orchid Win7 v1 <voi### [at] dev null> wrote:
> > What do you mean by "field"? Your question is not clear enough.
> I mean something like
> class Foobar
> {
> private:
> boost::shared_ptr<std::vector<Foo>> foo;
> public:
> Foobar()
> }
Why didn't you say so in the first place?
If you want to initialize that member function in the constructor, use
the constructor's initializer list or just assign to it in the contructor's
body. In the first case:
Foobar::Foobar(): foo(new std::vector<Foo>)
{}
Or if you prefer,
Foobar::Foobar()
{
foo = new std::vector<Foo>;
}
Btw, C++98 does not support >> for closing a double template. You have
to add a space in between.
I'm wondering why you are using a std::vector, though. I thought that what
you wanted was something like this:
//----------------------------------------------------------------
class Foobar
{
struct Impl;
boost::shared_ptr<Impl> impl;
public:
Foobar();
};
//----------------------------------------------------------------
In which case the implementation would be like:
//----------------------------------------------------------------
struct Foobar::Impl
{
std::vector<Foo> array;
}
Foobar::Foobar(): impl(new Impl)
{}
//----------------------------------------------------------------
Much simpler and cleaner that way.
> > (And btw, don't start names with an underscore. Those are reserved for
> > the compiler.)
> Hoooookay... In that case, there's about 200 lines in the existing
> codebase that need to be changed. o_O
I have never quite understood why so many programmers seem to be obsessed
with putting underscores at the beginning of names.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |