C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling Member function in constructor

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Biswajit Jena
Guest





PostPosted: Thu Dec 21, 2006 10:10 am    Post subject: Calling Member function in constructor Reply with 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 ?
Back to top
zhao.kaiyong@gmail.com
Guest





PostPosted: Thu Dec 21, 2006 10:10 am    Post subject: Re: Calling Member function in constructor Reply with quote



"Biswajit Jena дµÀ£º
"
Quote:
Is it possible to call a member function in constructor of the same
class ?

Yes.
Quote:

how ?

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





PostPosted: Thu Dec 21, 2006 10:11 am    Post subject: Re: Calling Member function in constructor Reply with quote



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





PostPosted: Thu Dec 21, 2006 10:11 am    Post subject: Re: Calling Member function in constructor Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.