Connecting Tech Pros Worldwide Help | Site Map

what does ~ mean before a function in C++

  #1  
Old July 23rd, 2005, 04:57 AM
QQ
Guest
 
Posts: n/a
for example
~CcMessage() {}

Thanks a lot!

I am a beginner for C++, so please forgive my stupid questions

  #2  
Old July 23rd, 2005, 04:57 AM
Marcin Kalicinski
Guest
 
Posts: n/a

re: what does ~ mean before a function in C++


> for example[color=blue]
> ~CcMessage() {}[/color]

It means that it is a destructor for class CcMessage.

cheers,
M.


  #3  
Old July 23rd, 2005, 04:58 AM
Samee Zahur
Guest
 
Posts: n/a

re: what does ~ mean before a function in C++


Since you say you are a beginner, I can't tell if you know what a class
means - if you do, a function like that inside a class named CcMessage
gets called each time an object of that class goes out of scope - it
performs certain cleanups needed to destroy the object.

Samee

  #4  
Old July 23rd, 2005, 04:59 AM
Mike Wahler
Guest
 
Posts: n/a

re: what does ~ mean before a function in C++



"QQ" <junciu@yahoo.com> wrote in message
news:1115228501.029669.103590@z14g2000cwz.googlegr oups.com...[color=blue]
> for example
> ~CcMessage() {}[/color]

It's a destructor. Look it up.
[color=blue]
> Thanks a lot!
>
> I am a beginner for C++, so please forgive my stupid questions[/color]

No need to 'forgive' you, only to recommend you
get a good textbook or two about C++. It's virtually
impossible to learn it without one.

For peer reviews see www.accu.org

-Mike


  #5  
Old July 23rd, 2005, 05:01 AM
Tim Slattery
Guest
 
Posts: n/a

re: what does ~ mean before a function in C++


"QQ" <junciu@yahoo.com> wrote:
[color=blue]
>for example
> ~CcMessage() {}[/color]

It means that this is the destructor function for class CcMessage. It
will be called when an object of class CcMessage is destroyed.

--
Tim Slattery
Slattery_T@bls.gov
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace function in Access seanmatthewwalsh@hotmail.com answers 1 June 27th, 2008 09:06 PM
How to reference function in shared function? Brett answers 4 November 21st, 2005 12:16 PM
Where can I find the implementation code for a function in C language? Stegano answers 14 November 14th, 2005 01:38 PM
I can't use an Array thats in un other Function in an other class?? BadOmen answers 10 July 17th, 2005 09:38 PM