3 Replies - 1269 Views - Last Post: 13 April 2011 - 03:00 AM Rate Topic: -----

#1 kcarriger  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-February 10

Why are double parentheses used in C++

Posted 12 April 2011 - 10:25 PM

Why are double parenthese used in C++?
Is This A Good Question/Topic? 0
  • +

Replies To: Why are double parentheses used in C++

#2 GhostOfPerdition  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 19
  • Joined: 11-April 11

Re: Why are double parentheses used in C++

Posted 12 April 2011 - 10:46 PM

The question seems a bit vague. Sometimes people (myself at times) like to use extra parentheses to clarify operator precedents... Do you have an example in mind?
Was This Post Helpful? 0
  • +
  • -

#3 kcarriger  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-February 10

Re: Why are double parentheses used in C++

Posted 12 April 2011 - 11:42 PM

View PostGhostOfPerdition, on 12 April 2011 - 11:46 PM, said:

The question seems a bit vague. Sometimes people (myself at times) like to use extra parentheses to clarify operator precedents... Do you have an example in mind?

Thank you, after really looking at the operation I had a feeling that is why they were there.

Example: if ((cookies>=1)&&(cookies<=40))

I am new at C++ but understand logical operators from digital electronics class. I am looking at different ways to write the same program using operators.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,667
  • Joined: 23-August 08

Re: Why are double parentheses used in C++

Posted 13 April 2011 - 03:00 AM

It's unnecessary in this case, but some people as a matter of habit wrap each boolean statement to be evaluated in its own set of parentheses for "clarity".
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1