From: "Uday Karan" <uday.karan@gmail.com>
To: Shriramana Sharma <samjnaa@gmail.com>,
linux-c-programming@vger.kernel.org
Subject: Re: Syntax of constructor
Date: Mon, 20 Mar 2006 09:04:31 +0530 [thread overview]
Message-ID: <4f2e7cd30603191934j468334eam34ecca31e49bf649@mail.gmail.com> (raw)
In-Reply-To: <200603200841.16674.samjnaa@gmail.com>
That's called the initializer list. I suggest you get a book that
explains these things. C++ Primer or The C++ Programming Language
would be good.
Here is a link that explains this particular topic:
http://www.blueturnip.com/projects/edu/cs/cpp/initializer-lists.html
-Uday
On 3/20/06, Shriramana Sharma <samjnaa@gmail.com> wrote:
> A header file contains the following class declaration:
>
> class CAA2DCoordinate
> {
> public:
> //Constructors / Destructors
> CAA2DCoordinate(): X(0), Y(0) {};
>
> //member variables
> double X;
> double Y;
> };
>
> Now what I do not understand is the line:
>
> CAA2DCoordinate(): X(0), Y(0) {};
>
> I would have thought it would be:
>
> CAA2DCoordinate() { X = 0; Y = 0; }
>
> just like the QDate constructor:
>
> QDate() { jd = 0; }
>
> What is the meaning of the colon ":" here, and what are the (0) things, and
> why are X and Y *outside* the braces?
>
> Thanks for your patience.
>
> --
>
> Tux #395953 resides at http://samvit.org
> playing with KDE 3.51 on SUSE Linux 10.0
> $ date [] CCE +2006-03-20 W12-1 UTC+0530
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2006-03-20 3:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-20 3:11 Syntax of constructor Shriramana Sharma
2006-03-20 3:34 ` Uday Karan [this message]
2006-03-20 8:17 ` Shriramana Sharma
2006-03-20 13:09 ` Glynn Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f2e7cd30603191934j468334eam34ecca31e49bf649@mail.gmail.com \
--to=uday.karan@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=samjnaa@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).