| View previous topic :: View next topic |
| Author |
Message |
Biswajit Jena Guest
|
Posted: Thu Dec 21, 2006 10:10 am Post subject: Calling Member function in constructor |
|
|
Is it possible to call a member function in constructor of the same
class ?
how ?
I have a templated member function which I want to call in the
constructor of the same class. How will I do it ? |
|
| Back to top |
|
 |
zhao.kaiyong@gmail.com Guest
|
Posted: Thu Dec 21, 2006 10:10 am Post subject: Re: Calling Member function in constructor |
|
|
"Biswajit Jena дµÀ£º
"
| Quote: | Is it possible to call a member function in constructor of the same
class ?
|
Yes.
class A{
A() { Init();}
~A(){}
Init(){}
}
| Quote: |
I have a templated member function which I want to call in the
constructor of the same class. How will I do it ? |
|
|
| Back to top |
|
 |
Craig Scott Guest
|
Posted: Thu Dec 21, 2006 10:11 am Post subject: Re: Calling Member function in constructor |
|
|
On Dec 21, 6:07 pm, "Biswajit Jena" <biswajit.t...@gmail.com> wrote:
| Quote: | Is it possible to call a member function in constructor of the same
class ?
how ?
I have a templated member function which I want to call in the
constructor of the same class. How will I do it ?
|
You should only call non-virtual member functions and static functions
of the class, since any subclass will not yet exist and so you won't
get the expected behavior if you call a virtual function. You call the
member/static functions just like you would in any other member
function. Apart from the caveat on virtual functions, a constructor
body acts pretty much just like any other member function.
--
Computational Fluid Dynamics, CSIRO (CMIS)
Melbourne, Australia |
|
| Back to top |
|
 |
Biswajit Jena Guest
|
Posted: Thu Dec 21, 2006 10:11 am Post subject: Re: Calling Member function in constructor |
|
|
Hi,
Thank you so much.
I am working on some BGL stuff.
Do you have any idea how to assign color value to vertices I add to a
newly created graph ?
Like I create a graph by manually adding vertices to it.
I also want to add color map to the vertices I add.
Do you know how to do this ?
Thanks
Biswajit Jena
zhao.kaiyong (AT) gmail (DOT) com wrote:
| Quote: | "Biswajit Jena дµÀ£º
"
Is it possible to call a member function in constructor of the same
class ?
Yes.
how ?
class A{
A() { Init();}
~A(){}
Init(){}
}
I have a templated member function which I want to call in the
constructor of the same class. How will I do it ? |
|
|
| Back to top |
|
 |
|