Constructor Initialization List With Non-NULL Pointers

Hi,
I'm starting to get the idea of these constructor initialization lists, but I still have one hang up. This comes about when I have pointers in my class. I have seen some examples where people have pointers and they pass a zero or NULL pointer inside the parentheses after that pointer. However, I'm wondering if there is a way to call new in the constructor initialization list, and if so, what the syntax would be.

For example, if I have the header:
1
2
3
4
5
6
class B;
class A
{
public:
 B*b;
}

Would I have the code file:
1
2
3
A:A():new b()
{
}

or
1
2
3
A:A():b(new B)
{
}

or simply skip new
1
2
3
A:A():b()
{
}

??? How does this work?
A:A():b(new B)

This.


The syntax for an initializer list is: varname(whater_you_want_to_contruct_it_with) ... just like a constructor.
Ok,
That is working, so here is my new version of the same question:
Suppose I have a pointer to many pointers--for example:
1
2
3
4
5
6
class B;
class A
{
public:
 B**b;
}

then how? I can't seem to find any syntax that will even compile. What am I missing?
Try this. You can replace the "2" with something else, of course.

1
2
3
4
A::A() : b(new B*[2])
{

}
Topic archived. No new replies allowed.