2 Replies - 12560 Views - Last Post: 20 June 2010 - 06:28 PM Rate Topic: -----

#1 heyoman1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 64
  • View blog
  • Posts: 735
  • Joined: 30-November 09

What does the tilde (~) mean in C++?

Posted 20 June 2010 - 06:19 PM

What does the tilde(~) mean in c++. and could you give an example also?
Is This A Good Question/Topic? 0
  • +

Replies To: What does the tilde (~) mean in C++?

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: What does the tilde (~) mean in C++?

Posted 20 June 2010 - 06:25 PM

It's the bitwise NOT

Quote

The bitwise NOT, or complement, is a unary operation that performs logical negation on each bit, forming the ones' complement of the given binary value. Digits which were 0 become 1, and vice versa. For example:

NOT 0111 (decimal 7)
= 1000 (decimal 8)

Was This Post Helpful? 1
  • +
  • -

#3 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: What does the tilde (~) mean in C++?

Posted 20 June 2010 - 06:28 PM

Or potentially a the beginning of a destructor.

class MyClass
{
    public:
        MyClass();
        ~MyClass();

    // ...
};


The constructor initializes instances of MyClass, while the destructor takes care of anything that needs to happen when the object is no longer needed. Essentially, they're the opposite. One creates, one destroys.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1