Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #12146
| From | ittium <ittium@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Argument type of function and safe types and types, arguments can handle safely |
| Date | 2011-12-08 12:01 +0530 |
| Organization | A noiseless patient Spider |
| Message-ID | <jbplnk$qrf$1@dont-email.me> (permalink) |
Groups, I have few doubts regarding argument type of function and types, arguments can handle safely. I know these issues have been discussed at multiple places on internet. I wanted to see the big picture and needed opinion of C++ gurus When you pass by value - Copy constructor is called (except for basic data type like int, float). you can pass the **same type variable** only When you pass by reference - A reference will be intialized with pass value. you can pass **non-const same type or derived type** (passing a constant type will return in error) When you pass by constant reference you can pass **const/non-const of same type or derived type**. When you pass by pointer - pointer is assigned to passed value you can pass **same type of derived type**. Cases written above are safe conversion (no casting is needed). **C++ compiler will not allow any other conversion **. You can still use casting for not allowed cases. My doubts are - Have I captured all the cases or there are some more cases (I will appreciate a link to a small reference) -What casts are safe e.g in case of pass by value casting from short to int seems perfectly safe. (I will appreciate a link to any document explaining safe casting) thanks Ittium
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
Argument type of function and safe types and types, arguments can handle safely ittium <ittium@gmail.com> - 2011-12-08 12:01 +0530
Re: Argument type of function and safe types and types, arguments can handle safely Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-08 02:17 -0600
Re: Argument type of function and safe types and types, arguments can handle safely 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-08 00:31 -0800
Re: Argument type of function and safe types and types, arguments can handle safely ittium <ittium@gmail.com> - 2011-12-08 16:57 +0530
Re: Argument type of function and safe types and types, arguments can handle safely Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-08 12:32 -0600
Re: Argument type of function and safe types and types, arguments can handle safely Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-12-08 20:00 +0000
Re: Argument type of function and safe types and types, arguments can handle safely Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-08 14:30 -0600
Re: Argument type of function and safe types and types, arguments can handle safely Goran <goran.pusic@gmail.com> - 2011-12-09 03:05 -0800
csiph-web