By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,388 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,388 IT Pros & Developers. It's quick & easy.

static_cast versus C-style type cast

P: n/a
Is there a difference between a static_cast and an C-style type cast?

In other words, is there a difference between...

int a;
unsigned b = static_cast<unsigned>(a); // static_cast
unsigned c = (unsigned)(a); // C-style cast

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dave Rahardja wrote:
Is there a difference between a static_cast and an C-style type cast?
Yes.
In other words, is there a difference between...

int a;
unsigned b = static_cast<unsigned>(a); // static_cast
unsigned c = (unsigned)(a); // C-style cast


No.
A static_cast is more restrictive than a C style cast. The latter will
do the same as any combination of static_cast, const_cast and
reinterpret_cast that is necessary for the requested convertion.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.