May 5, 2011

leon.anavi leon.anavi
Mad Scientist
1193 posts

[SOLVED] You are not allowed to edit this page.

 

Hi,

Why I am not able to edit this page [developer.qt.nokia.com] ?

I would like to replace the C style cast:

  1. double c = (double) a / b;

with static_cast due to its advantages:

  1. double c = static_cast<double>(a/b);

Using C style cast in C++ source code is a bad practice and should not exist in this code snippet!

Thanks,
Leon

 Signature 

http://anavi.org/

7 replies

May 5, 2011

Volker Volker
Ant Farmer
5428 posts

I don’t know why the page is locked (someone else is trying to edit?)

But your correction is wrong!

You calculate the division using integers and cast that result to a double, which leads to the undesired reusult of 0. If you really want to use a c++ cast, then it must be

  1. double c = static_cast<double>(a)/b;

Using C-style casts for number conversions is acceptable, IMHO. So if you really want to add static cast, add it as an alternative.

May 5, 2011

leon.anavi leon.anavi
Mad Scientist
1193 posts

Volker wrote:

But your correction is wrong!

You calculate the division using integers and cast that result to a double, which leads to the undesired reusult of 0. If you really want to use a c++ cast, then it must be

  1. double c = static_cast<double>(a)/b;

Hi Volker,

Yes, of course! Thanks for pointing it out – it was a silly typing mistake I did not want to change the algorithm just the C style cast :)

I insist on adding an example with static_cast, but I still cannot edit the page. I will try again tomorrow. Btw do you get the same message if you try to edit it?

Thanks,
Leon

 Signature 

http://anavi.org/

May 5, 2011

Volker Volker
Ant Farmer
5428 posts

Hi Leon,
yes, I get the same message, I cannot edit it either. If it’s still locked tomorrow, I’ll point some of the DevNet devs to it.

May 5, 2011

HuXiKa HuXiKa
Lab Rat
83 posts

If you want to add a few examples, you should include this [stackoverflow.com] too. It’s a must read for everyone.

 Signature 

If you can find faults of spelling in the text above, you can keep them.

May 5, 2011

leon.anavi leon.anavi
Mad Scientist
1193 posts
Volker wrote:
Hi Leon, yes, I get the same message, I cannot edit it either. If it’s still locked tomorrow, I’ll point some of the DevNet devs to it.

Hi Volker,

I still get the same message. Can you please notify DevNet devs about this issue?

HuXiKa wrote:
If you want to add a few examples, you should include this [stackoverflow.com] too. It’s a must read for everyone.

Thanks for the link. You can add such kind of information to Qt DevNet wiki yourself too. Just find and appropriate article or create a new one. Do not hesitate and help us extend the wiki :)

10x,
Leon

 Signature 

http://anavi.org/

May 5, 2011

Alexandra Alexandra
Hobby Entomologist
607 posts

It was locked. No idea why. Now it’s unlocked and you can edit it. :)

 Signature 

*THE CAKE IS A LIE*
Web Community Manager - Qt Development Frameworks

May 5, 2011

leon.anavi leon.anavi
Mad Scientist
1193 posts
Alexandra wrote:
It was locked. No idea why. Now it’s unlocked and you can edit it. :)

Alexandra, Volker, thanks! :) I have successfully add an example with static_cast.

Thanks,
Leon

 Signature 

http://anavi.org/

 
  ‹‹ MeeGo Application Development Using Qt      Qt5 development primer ››

You must log in to post a reply. Not a member yet? Register here!