what does ~ mean before a function in C++

Q

QQ

for example
~CcMessage() {}

Thanks a lot!

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

Tim Slattery

QQ said:
for example
~CcMessage() {}

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

Samee Zahur

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
 
M

Mike Wahler

QQ said:
for example
~CcMessage() {}

It's a destructor. Look it up.
Thanks a lot!

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top