Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
C++: Is This a Valid Function Signiture?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
wswartzendruber
Veteran
Veteran


Joined: 23 Mar 2004
Posts: 1261
Location: Idaho, USA

PostPosted: Sat Oct 03, 2009 3:28 am    Post subject: C++: Is This a Valid Function Signiture? Reply with quote

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
View user's profile Send private message
yabbadabbadont
Advocate
Advocate


Joined: 14 Mar 2003
Posts: 4791
Location: 2 exits past crazy

PostPosted: Sat Oct 03, 2009 4:25 am    Post subject: Reply with quote

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
View user's profile Send private message
dmitchell
Veteran
Veteran


Joined: 17 May 2003
Posts: 1159
Location: Austin, Texas

PostPosted: Sun Oct 04, 2009 5:23 am    Post subject: Re: C++: Is This a Valid Function Signiture? Reply with quote

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
View user's profile Send private message
wswartzendruber
Veteran
Veteran


Joined: 23 Mar 2004
Posts: 1261
Location: Idaho, USA

PostPosted: Sun Oct 04, 2009 5:47 am    Post subject: Reply with quote

C++ confuses the hell out of me. C# just made sense.
_________________
Git has obsoleted SVN.
10mm Auto has obsoleted 45 ACP.
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Sun Oct 04, 2009 6:03 am    Post subject: Reply with quote

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
View user's profile Send private message
wswartzendruber
Veteran
Veteran


Joined: 23 Mar 2004
Posts: 1261
Location: Idaho, USA

PostPosted: Sun Oct 04, 2009 6:05 am    Post subject: Reply with quote

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
View user's profile Send private message
gms1
n00b
n00b


Joined: 10 Oct 2008
Posts: 27

PostPosted: Sun Oct 04, 2009 7:41 am    Post subject: Reply with quote

wswartzendruber wrote:
I prefer something well-designed from the ground up.


I do not want to simulate default parameters:
http://msdn.microsoft.com/en-us/library/aa287762(VS.71).aspx
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Sun Oct 04, 2009 8:03 am    Post subject: Reply with quote

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
View user's profile Send private message
165177
Apprentice
Apprentice


Joined: 27 Apr 2007
Posts: 156

PostPosted: Sun Oct 04, 2009 12:17 pm    Post subject: Reply with quote

@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
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Sun Oct 04, 2009 1:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
wswartzendruber
Veteran
Veteran


Joined: 23 Mar 2004
Posts: 1261
Location: Idaho, USA

PostPosted: Sun Oct 04, 2009 2:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Sun Oct 04, 2009 3:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
165177
Apprentice
Apprentice


Joined: 27 Apr 2007
Posts: 156

PostPosted: Sun Oct 04, 2009 3:21 pm    Post subject: Reply with quote

Will you try to live that day without anything from Sun? ;)
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Sun Oct 04, 2009 4:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
wswartzendruber
Veteran
Veteran


Joined: 23 Mar 2004
Posts: 1261
Location: Idaho, USA

PostPosted: Sun Oct 04, 2009 4:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
yabbadabbadont
Advocate
Advocate


Joined: 14 Mar 2003
Posts: 4791
Location: 2 exits past crazy

PostPosted: Sun Oct 04, 2009 11:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum