By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,912 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,912 IT Pros & Developers. It's quick & easy.

Calling Member function in constructor

P: n/a
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 ?

Dec 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"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 ?
Dec 21 '06 #2

P: n/a


On Dec 21, 6:07 pm, "Biswajit Jena" <biswajit.t...@gmail.comwrote:
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

Dec 21 '06 #3

P: n/a
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
zh**********@gmail.com wrote:
"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 ?
Dec 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.