View previous topic :: View next topic |
Author |
Message |
wswartzendruber Veteran
Joined: 23 Mar 2004 Posts: 1261 Location: Idaho, USA
|
Posted: Sat Oct 03, 2009 3:28 am Post subject: C++: Is This a Valid Function Signiture? |
|
|
I'm a little uneasy about defaulting a "const QString &" to zero. What does that "const &" thingie mean anyway?
Code: | GNUArgumentParser(int argc, char* argv[], const QString & options = 0); |
_________________ Git has obsoleted SVN.
10mm Auto has obsoleted 45 ACP. |
|
Back to top |
|
|
yabbadabbadont Advocate
Joined: 14 Mar 2003 Posts: 4791 Location: 2 exits past crazy
|
Posted: Sat Oct 03, 2009 4:25 am Post subject: |
|
|
It means that the third parameter is optional and defaults to zero (NULL) if not supplied. Although I guess you already knew that. It also means that the third parameter is a reference to an object of type QString (think passed by reference) and because it is a const reference, it cannot be modified within this function.
(Disclaimer: It has been 4-1/2 years since I actually used C++ on a regular basis...) |
|
Back to top |
|
|
dmitchell Veteran
Joined: 17 May 2003 Posts: 1159 Location: Austin, Texas
|
Posted: Sun Oct 04, 2009 5:23 am Post subject: Re: C++: Is This a Valid Function Signiture? |
|
|
wswartzendruber wrote: | Code: | GNUArgumentParser(int argc, char* argv[], const QString & options = 0); |
|
This works because QString has a non-explicit constructor that takes a char const* so the compiler can construct a QString from 0. A better idea is to make the default options a default-constructed QString:
Code: | GNUArgumentParser(int argc, char* argv[], const QString & options = QString()); |
_________________ Your argument is invalid. |
|
Back to top |
|
|
wswartzendruber Veteran
Joined: 23 Mar 2004 Posts: 1261 Location: Idaho, USA
|
Posted: Sun Oct 04, 2009 5:47 am Post subject: |
|
|
C++ confuses the hell out of me. C# just made sense. _________________ Git has obsoleted SVN.
10mm Auto has obsoleted 45 ACP. |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Sun Oct 04, 2009 6:03 am Post subject: |
|
|
wswartzendruber wrote: | C++ confuses the hell out of me. C# just made sense. |
nahhh, C# is for woosiess... _________________ Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein |
|
Back to top |
|
|
wswartzendruber Veteran
Joined: 23 Mar 2004 Posts: 1261 Location: Idaho, USA
|
Posted: Sun Oct 04, 2009 6:05 am Post subject: |
|
|
DaggyStyle wrote: | wswartzendruber wrote: | C++ confuses the hell out of me. C# just made sense. |
nahhh, C# is for woosiess... |
Hey, if C++ adds four inches to your schlong, than more power to ya. I'm just learning this language because my university's about to wreak havoc on me with it. I prefer something well-designed from the ground up. _________________ Git has obsoleted SVN.
10mm Auto has obsoleted 45 ACP. |
|
Back to top |
|
|
gms1 n00b
Joined: 10 Oct 2008 Posts: 27
|
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Sun Oct 04, 2009 8:03 am Post subject: |
|
|
wswartzendruber wrote: | DaggyStyle wrote: | wswartzendruber wrote: | C++ confuses the hell out of me. C# just made sense. |
nahhh, C# is for woosiess... |
Hey, if C++ adds four inches to your schlong, than more power to ya. I'm just learning this language because my university's about to wreak havoc on me with it. I prefer something well-designed from the ground up. |
want a easy oo language, go to the source, e.g. java, not the copy (; _________________ Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein |
|
Back to top |
|
|
165177 Apprentice
Joined: 27 Apr 2007 Posts: 156
|
Posted: Sun Oct 04, 2009 12:17 pm Post subject: |
|
|
@DaggyStyle: You think, Java is easy? Try to explain the difference between Integer and int and the concept of Auto(un)boxing to a beginner
@gms1: C# 4.0 will have optional and named parameters. |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Sun Oct 04, 2009 1:02 pm Post subject: |
|
|
lunar wrote: | @DaggyStyle: You think, Java is easy? Try to explain the difference between Integer and int and the concept of Auto(un)boxing to a beginner |
did it she understood right away. _________________ Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein |
|
Back to top |
|
|
wswartzendruber Veteran
Joined: 23 Mar 2004 Posts: 1261 Location: Idaho, USA
|
Posted: Sun Oct 04, 2009 2:21 pm Post subject: |
|
|
DaggyStyle wrote: | wswartzendruber wrote: | DaggyStyle wrote: | wswartzendruber wrote: | C++ confuses the hell out of me. C# just made sense. |
nahhh, C# is for woosiess... |
Hey, if C++ adds four inches to your schlong, than more power to ya. I'm just learning this language because my university's about to wreak havoc on me with it. I prefer something well-designed from the ground up. |
want a easy oo language, go to the source, e.g. java, not the copy (; |
Implement the fast square root algorithm (from Quake) in Java, do some pointer arithmetic, and then come talk to me. _________________ Git has obsoleted SVN.
10mm Auto has obsoleted 45 ACP. |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Sun Oct 04, 2009 3:10 pm Post subject: |
|
|
wswartzendruber wrote: | DaggyStyle wrote: | wswartzendruber wrote: | DaggyStyle wrote: | wswartzendruber wrote: | C++ confuses the hell out of me. C# just made sense. |
nahhh, C# is for woosiess... |
Hey, if C++ adds four inches to your schlong, than more power to ya. I'm just learning this language because my university's about to wreak havoc on me with it. I prefer something well-designed from the ground up. |
want a easy oo language, go to the source, e.g. java, not the copy (; |
Implement the fast square root algorithm (from Quake) in Java, do some pointer arithmetic, and then come talk to me. |
try to live a day without anything from ms and then come to me _________________ Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein |
|
Back to top |
|
|
165177 Apprentice
Joined: 27 Apr 2007 Posts: 156
|
Posted: Sun Oct 04, 2009 3:21 pm Post subject: |
|
|
Will you try to live that day without anything from Sun? |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Sun Oct 04, 2009 4:42 pm Post subject: |
|
|
lunar wrote: | Will you try to live that day without anything from Sun? |
done that too _________________ Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein |
|
Back to top |
|
|
wswartzendruber Veteran
Joined: 23 Mar 2004 Posts: 1261 Location: Idaho, USA
|
Posted: Sun Oct 04, 2009 4:47 pm Post subject: |
|
|
DaggyStyle wrote: | wswartzendruber wrote: | DaggyStyle wrote: | wswartzendruber wrote: | DaggyStyle wrote: | wswartzendruber wrote: | C++ confuses the hell out of me. C# just made sense. |
nahhh, C# is for woosiess... |
Hey, if C++ adds four inches to your schlong, than more power to ya. I'm just learning this language because my university's about to wreak havoc on me with it. I prefer something well-designed from the ground up. |
want a easy oo language, go to the source, e.g. java, not the copy (; |
Implement the fast square root algorithm (from Quake) in Java, do some pointer arithmetic, and then come talk to me. |
try to live a day without anything from ms and then come to me |
Sure...
Code: | thinkpad ~ # fdisk /dev/sda
The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x43c5ef27
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40131 83 Linux
/dev/sda2 6 60801 488343870 83 Linux |
_________________ Git has obsoleted SVN.
10mm Auto has obsoleted 45 ACP. |
|
Back to top |
|
|
yabbadabbadont Advocate
Joined: 14 Mar 2003 Posts: 4791 Location: 2 exits past crazy
|
Posted: Sun Oct 04, 2009 11:35 pm Post subject: |
|
|
wswartzendruber wrote: | Sure...
Code: | thinkpad ~ # fdisk /dev/sda
The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x43c5ef27
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40131 83 Linux
/dev/sda2 6 60801 488343870 83 Linux |
|
So, what about sdb, sdc, etc.?
By the way, just use "fdisk -l" and all partitions on all fixed drives will be displayed. |
|
Back to top |
|
|
|