473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

initialization vs assignment

Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.

-charles
Jul 22 '05 #1
50 3729
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor
Jul 22 '05 #2
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor
Jul 22 '05 #3
Charles Stapleton wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to
setting the member variables a and b using initialization, :a(i), as
opposed to using assignment, b = j.

-charles


IMHO, nothing, but when you have a variable of a class with no default
constructor, initialization is required.

- Pete
Jul 22 '05 #4
Charles Stapleton wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to
setting the member variables a and b using initialization, :a(i), as
opposed to using assignment, b = j.

-charles


IMHO, nothing, but when you have a variable of a class with no default
constructor, initialization is required.

- Pete
Jul 22 '05 #5
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.
For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).
-leor

-charles


--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #6
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.
For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).
-leor

-charles


--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #7
* Leor Zolman <le**@bdsoft.com> schriebt:
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).


For answers like these I think it's a good idea to refer to the FAQ.

FAQ: <url: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6>.

Unfortunately the FAQ does not mention the single most common "good" reason
to use assignment, namely, presence of initialization order dependencies.
Which should be designed away if possible, but that is sometimes impractical.
As a rule, if assignment is used instead of initialization list then either
there is an initialization order dependency or a newbie or both.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #8
* Leor Zolman <le**@bdsoft.com> schriebt:
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).


For answers like these I think it's a good idea to refer to the FAQ.

FAQ: <url: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6>.

Unfortunately the FAQ does not mention the single most common "good" reason
to use assignment, namely, presence of initialization order dependencies.
Which should be designed away if possible, but that is sometimes impractical.
As a rule, if assignment is used instead of initialization list then either
there is an initialization order dependency or a newbie or both.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #9
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #10
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #11
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?

Because
Jul 22 '05 #12
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?

Because
Jul 22 '05 #13
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to setting >> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor

Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #14
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to setting >> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor

Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #15
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all over
the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first place,
but then MIT has not only the best & brightest of the US population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented university.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #16
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all over
the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first place,
but then MIT has not only the best & brightest of the US population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented university.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #17
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:

> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to

setting
>> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor
Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


It could just as well be taken at its face value. What's your F point?
Jul 22 '05 #18
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:

> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to

setting
>> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor
Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


It could just as well be taken at its face value. What's your F point?
Jul 22 '05 #19
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #20
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #21
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.


Hah, one should never needlessly limit an attack to person and country, as I
am sure your mother told you.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.
Yada yada yada, "AFAIK there are many good negroes, jews, japs, frogs, etc.,
and one of my best friends is a lesbian". Actually there are. One of the
nice things about Norway is the humanitarian outlook (it's nice in general,
but as commented earlier not so good with respect to technical education).
E.g. we were early (1981) with having a female prime minister (Gro Harlem
Brundtland, <url: http://tinyurl.com/26x63>); then a female and lesbian
minister of justice (Anne Holt, who now mainly writes detective novels, <url:
http://tinyurl.com/34uby>, <url: http://tinyurl.com/yuqcc>), and currently a
male homosexual minister of economy (Per-Kristian Foss, <url:
http://tinyurl.com/3fsdm>) with a priest (Kjell Magne Bondevik, <url:
http://tinyurl.com/2azkv>) as prime minister -- we're simply not bigots, we
don't have that in us, but look at the US... When is the first lesbian
president or even member of Congress expected in the US? Never, I think;
and to take but one little example from current political debate, note that
in Per-Kristian Foss' official CV (from the Norwegian government), referred
above, he lives in a registered partnership -- when is that in the US?

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.


RTFM on topicality.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #22
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.


Hah, one should never needlessly limit an attack to person and country, as I
am sure your mother told you.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.
Yada yada yada, "AFAIK there are many good negroes, jews, japs, frogs, etc.,
and one of my best friends is a lesbian". Actually there are. One of the
nice things about Norway is the humanitarian outlook (it's nice in general,
but as commented earlier not so good with respect to technical education).
E.g. we were early (1981) with having a female prime minister (Gro Harlem
Brundtland, <url: http://tinyurl.com/26x63>); then a female and lesbian
minister of justice (Anne Holt, who now mainly writes detective novels, <url:
http://tinyurl.com/34uby>, <url: http://tinyurl.com/yuqcc>), and currently a
male homosexual minister of economy (Per-Kristian Foss, <url:
http://tinyurl.com/3fsdm>) with a priest (Kjell Magne Bondevik, <url:
http://tinyurl.com/2azkv>) as prime minister -- we're simply not bigots, we
don't have that in us, but look at the US... When is the first lesbian
president or even member of Congress expected in the US? Never, I think;
and to take but one little example from current political debate, note that
in Per-Kristian Foss' official CV (from the Norwegian government), referred
above, he lives in a registered partnership -- when is that in the US?

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.


RTFM on topicality.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #23
Alf P. Steinbach wrote:
RTFM on topicality.

I trust you can find a Norwegian translation of the Hávamál by starting
here: http://www.forn-sed.no/main/nynorsk/informasjon.htm

From the Old Norse:

9. Sá er sæll
er sjálfr of á
lof ok vit, meðan lifir;
því at ill ráð
hefr maðr oft þegit
annars brjóstum ór.

10. Byrði betri
berr-at maðr brautu at
en sé mannvit mikit;
auði betra
þykkir þat í ókunnum stað;
slíkt er válaðs vera.

11. Byrði betri
berr-at maðr brautu at
en sé mannvit mikit;
vegnest verra
vegr-a hann velli at
en sé ofdrykkja öls.

12. Er-a svá gótt
sem gótt kveða
öl alda sonum,
því at færa veit
er fleira drekkr
síns til geðs gumi.

13. Óminnishegri heitir
sá er yfir ölðrum þrumir;
hann stelr geði guma;
þess fugls fjöðrum
ek fjötraðr vark
í garði Gunnlaðar.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #24
Alf P. Steinbach wrote:
RTFM on topicality.

I trust you can find a Norwegian translation of the Hávamál by starting
here: http://www.forn-sed.no/main/nynorsk/informasjon.htm

From the Old Norse:

9. Sá er sæll
er sjálfr of á
lof ok vit, meðan lifir;
því at ill ráð
hefr maðr oft þegit
annars brjóstum ór.

10. Byrði betri
berr-at maðr brautu at
en sé mannvit mikit;
auði betra
þykkir þat í ókunnum stað;
slíkt er válaðs vera.

11. Byrði betri
berr-at maðr brautu at
en sé mannvit mikit;
vegnest verra
vegr-a hann velli at
en sé ofdrykkja öls.

12. Er-a svá gótt
sem gótt kveða
öl alda sonum,
því at færa veit
er fleira drekkr
síns til geðs gumi.

13. Óminnishegri heitir
sá er yfir ölðrum þrumir;
hann stelr geði guma;
þess fugls fjöðrum
ek fjötraðr vark
í garði Gunnlaðar.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #25
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hávamál


The English translation is actually more understandable.

Have you considered verses 1 through 8, not just 9 through 13? ;-)

Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ. What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".

Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #26
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hávamál


The English translation is actually more understandable.

Have you considered verses 1 through 8, not just 9 through 13? ;-)

Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ. What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".

Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #27
PS: My information about the US Congress turned out to be out of date.
It actually had Tammy Baldwin in 1998. So my guess was partially
incorrect.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #28
PS: My information about the US Congress turned out to be out of date.
It actually had Tammy Baldwin in 1998. So my guess was partially
incorrect.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #29
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hávamál
The English translation is actually more understandable.


They all seem lacking to me. I prefer the Old Norse.
Have you considered verses 1 through 8, not just 9 through 13? ;-)
Certainly, but they didn't seem as apropos.
Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ.
I didn't say it was equivalent. I said it might be taken that way.
What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".
I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf


What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #30
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hávamál
The English translation is actually more understandable.


They all seem lacking to me. I prefer the Old Norse.
Have you considered verses 1 through 8, not just 9 through 13? ;-)
Certainly, but they didn't seem as apropos.
Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ.
I didn't say it was equivalent. I said it might be taken that way.
What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".
I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf


What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #31
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
I guess you mean why it should be preferred over assignment. In this
case, with 'int' type, and nothing else going on in the constructor, I
see no technical reason and no readability reason. But it's like
a car driver indicating which way he's about to drive at crossroads even
when there are no other cars in sight: the habit helps to do the Right
Thing in general, and perhaps there's someone waiting to cross the
street, just not very clearly in sight, making the decision to cross...

Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.

What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.


I'm not sure whether this is some subtle thing or a hint about off-topicality
or an effort to convince me that you are no dummy (I do know, at least if
earlier comments about implementing mathematical models is true), or boasting,
or what. But it doesn't seem very relevant. If it's simply "by the way I met
a famous person", well most of us have; e.g. I shook hands with Bill Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to a
shop by security guards, then came Bill, and of course he had to shake hands
with a beautiful lady beside me, and another one, and then for consistency
with me too as the last person before the entrance to the shop. Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in the
span of just one week, and actually shook hands with one of them!

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #32
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
I guess you mean why it should be preferred over assignment. In this
case, with 'int' type, and nothing else going on in the constructor, I
see no technical reason and no readability reason. But it's like
a car driver indicating which way he's about to drive at crossroads even
when there are no other cars in sight: the habit helps to do the Right
Thing in general, and perhaps there's someone waiting to cross the
street, just not very clearly in sight, making the decision to cross...

Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.

What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.


I'm not sure whether this is some subtle thing or a hint about off-topicality
or an effort to convince me that you are no dummy (I do know, at least if
earlier comments about implementing mathematical models is true), or boasting,
or what. But it doesn't seem very relevant. If it's simply "by the way I met
a famous person", well most of us have; e.g. I shook hands with Bill Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to a
shop by security guards, then came Bill, and of course he had to shake hands
with a beautiful lady beside me, and another one, and then for consistency
with me too as the last person before the entrance to the shop. Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in the
span of just one week, and actually shook hands with one of them!

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #33
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.
I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)
Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.
Thanks for the pointer, I still have a lot to internalize.
What Gore really meant when he pointed to his work with the Internet was
not that he invented the Internet - which he never said - but that he did
a lot to popularize it, and disseminate information about the use of web
browsers
to people in prominant and influential positions. I set up the systems
he use to do it.
I'm not sure whether this is some subtle thing


The point was I might be a bit new to this particular newsgroup, but I'm not
new to usenet. At some point I'm no longer a newbie in this newsgroup.
For me to comment on how others are treated is not necessarily improper for
a guest (the Hávamál is the song of a wandering singer), but I think I've
been around long enough to not qualify as a newbie.
But it doesn't seem very relevant. If it's simply "by the way I met a famous person", well most of us have; e.g. I shook hands with Bill
Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to
a shop by security guards, then came Bill, and then for consistency with me too as the last person before the
entrance to the shop.


I hope you washed your hand with hot water and soap before touching
anything, especially your face, or other sensitive part of your body.
Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it
wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in
the span of just one week, and actually shook hands with one of them!


I met Stephen Wolfram, and didn't even know it at the time. I never met
Gore, I just set up the systems. I'm far more pleased to have had a chance
to meet and interact with John A. Wheeler, than I would be to have met
Gore.

http://pupgg.princeton.edu/www/jh/an...symposium.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #34
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.
I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)
Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.
Thanks for the pointer, I still have a lot to internalize.
What Gore really meant when he pointed to his work with the Internet was
not that he invented the Internet - which he never said - but that he did
a lot to popularize it, and disseminate information about the use of web
browsers
to people in prominant and influential positions. I set up the systems
he use to do it.
I'm not sure whether this is some subtle thing


The point was I might be a bit new to this particular newsgroup, but I'm not
new to usenet. At some point I'm no longer a newbie in this newsgroup.
For me to comment on how others are treated is not necessarily improper for
a guest (the Hávamál is the song of a wandering singer), but I think I've
been around long enough to not qualify as a newbie.
But it doesn't seem very relevant. If it's simply "by the way I met a famous person", well most of us have; e.g. I shook hands with Bill
Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to
a shop by security guards, then came Bill, and then for consistency with me too as the last person before the
entrance to the shop.


I hope you washed your hand with hot water and soap before touching
anything, especially your face, or other sensitive part of your body.
Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it
wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in
the span of just one week, and actually shook hands with one of them!


I met Stephen Wolfram, and didn't even know it at the time. I never met
Gore, I just set up the systems. I'm far more pleased to have had a chance
to meet and interact with John A. Wheeler, than I would be to have met
Gore.

http://pupgg.princeton.edu/www/jh/an...symposium.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #35
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean by
formal language mechanism is the C++ definition of initializer list. You'll
find that in section §12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.

Possibility 2: what you mean by formal language mechanism is a language-
independent thing that §12.6.2 is the C++ language implementation of. Sorry,
can't help you there. Except that it's possible to find formal definitions
of just about anything just by looking and searching hard enough; and if one
does not exist it can always be produced.

Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it? Well, one thing
that is different between Java and C++ is that a Java object of a type with
constructor can only be referred to by reference, whereas in C++ it can be
a local variable say (or directly occupy storage in another object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design choice
is then between (A) not having automatic constructor calls but instead require
the equivalent of placement new for all subobjects, one can't just leave the
members as null-references as in Java, and (B) having automatic constructor
calls, in which case additional initialization in the constructor body will
be inefficient, and there is the problem of providing constructor arguments.
C++ uses solution (B), and solves the both inefficiency problem and the
argument passing problem with the constructor initializer lists mechanism.

In addition constructor initializer lists solve the problem of initializing
const members.

But an alternative to that could be not to design the language with const
members but with 'readonly' members which turn to 'readonly' state only
after the constructor has finished.

I met Stephen Wolfram, and didn't even know it at the time.
You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:

perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'

John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #36
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean by
formal language mechanism is the C++ definition of initializer list. You'll
find that in section §12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.

Possibility 2: what you mean by formal language mechanism is a language-
independent thing that §12.6.2 is the C++ language implementation of. Sorry,
can't help you there. Except that it's possible to find formal definitions
of just about anything just by looking and searching hard enough; and if one
does not exist it can always be produced.

Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it? Well, one thing
that is different between Java and C++ is that a Java object of a type with
constructor can only be referred to by reference, whereas in C++ it can be
a local variable say (or directly occupy storage in another object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design choice
is then between (A) not having automatic constructor calls but instead require
the equivalent of placement new for all subobjects, one can't just leave the
members as null-references as in Java, and (B) having automatic constructor
calls, in which case additional initialization in the constructor body will
be inefficient, and there is the problem of providing constructor arguments.
C++ uses solution (B), and solves the both inefficiency problem and the
argument passing problem with the constructor initializer lists mechanism.

In addition constructor initializer lists solve the problem of initializing
const members.

But an alternative to that could be not to design the language with const
members but with 'readonly' members which turn to 'readonly' state only
after the constructor has finished.

I met Stephen Wolfram, and didn't even know it at the time.
You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:

perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'

John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #37
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
> * "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
>>
>> I still don't fully understand /why/ m_x(x) works in the following:
>>
>> #include <iostream>
>>
>> class A {
>> int m_x;
>> public:
>> A(int x):m_x(x){};
> I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism.
That's why I'm sitting here with the Standard and a highlighter. Yes,
it's in hardcopy printed using psutils. I'm not using the highlighter on
the electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean
by
formal language mechanism is the C++ definition of initializer list.
You'll
find that in section §12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.


Thanks for the pointer. But that's not what has me puzzled.
Possibility 2: what you mean by formal language mechanism is a language-
independent thing that §12.6.2 is the C++ language implementation of.
I don't believe it's an implementation issue.
Sorry,
can't help you there. Except that it's possible to find formal
definitions of just about anything just by looking and searching hard
enough; and if one does not exist it can always be produced.
Nobody ever responded to my question about what else significant is on the
page of K&R in the Grammar where the function main() is specified. I
wonder why.
Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it?
Nope.
Well, one
thing that is different between Java and C++ is that a Java object of a
type with constructor can only be referred to by reference, whereas in C++
it can be a local variable say (or directly occupy storage in another
object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design
choice is then between (A) not having automatic constructor calls but
instead require the equivalent of placement new for all subobjects, one
can't just leave the members as null-references as in Java, and (B) having
automatic constructor calls, in which case additional initialization in
the constructor body will be inefficient, and there is the problem of
providing constructor arguments. C++ uses solution (B), and solves the
both inefficiency problem and the argument passing problem with the
constructor initializer lists mechanism.
I guess there are advantages to any of the approaches. Java is a very
regular language which may be a bit awkward at times, but it's also
straightforward. C++ reminds me of something Mithrandir might study. There
seems to be a lot of magic in it. Hard to master, hard to perceive, but
powerful when you do master it.
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}
I met Stephen Wolfram, and didn't even know it at the time.


You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:


I don't know if I'm susceptible to fullblown Cellular Automata. I've done a
lot of fun stuff in Mathematica, but there is something fundamental I have
yet to grasp. It may be something it shares with Lisp, which I've never
mastered. I know it has to do with up-values. But I don't even want to
think about that right now.
perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'
And you suggested "UBC" was profane in C++ circles? ;-)
John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)


Don't know the book, but this will tell you more about Wheeler:
http://www.usd.edu/phys/courses/phys...k/wheeler.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #38
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
> * "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
>>
>> I still don't fully understand /why/ m_x(x) works in the following:
>>
>> #include <iostream>
>>
>> class A {
>> int m_x;
>> public:
>> A(int x):m_x(x){};
> I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism.
That's why I'm sitting here with the Standard and a highlighter. Yes,
it's in hardcopy printed using psutils. I'm not using the highlighter on
the electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean
by
formal language mechanism is the C++ definition of initializer list.
You'll
find that in section §12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.


Thanks for the pointer. But that's not what has me puzzled.
Possibility 2: what you mean by formal language mechanism is a language-
independent thing that §12.6.2 is the C++ language implementation of.
I don't believe it's an implementation issue.
Sorry,
can't help you there. Except that it's possible to find formal
definitions of just about anything just by looking and searching hard
enough; and if one does not exist it can always be produced.
Nobody ever responded to my question about what else significant is on the
page of K&R in the Grammar where the function main() is specified. I
wonder why.
Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it?
Nope.
Well, one
thing that is different between Java and C++ is that a Java object of a
type with constructor can only be referred to by reference, whereas in C++
it can be a local variable say (or directly occupy storage in another
object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design
choice is then between (A) not having automatic constructor calls but
instead require the equivalent of placement new for all subobjects, one
can't just leave the members as null-references as in Java, and (B) having
automatic constructor calls, in which case additional initialization in
the constructor body will be inefficient, and there is the problem of
providing constructor arguments. C++ uses solution (B), and solves the
both inefficiency problem and the argument passing problem with the
constructor initializer lists mechanism.
I guess there are advantages to any of the approaches. Java is a very
regular language which may be a bit awkward at times, but it's also
straightforward. C++ reminds me of something Mithrandir might study. There
seems to be a lot of magic in it. Hard to master, hard to perceive, but
powerful when you do master it.
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}
I met Stephen Wolfram, and didn't even know it at the time.


You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:


I don't know if I'm susceptible to fullblown Cellular Automata. I've done a
lot of fun stuff in Mathematica, but there is something fundamental I have
yet to grasp. It may be something it shares with Lisp, which I've never
mastered. I know it has to do with up-values. But I don't even want to
think about that right now.
perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'
And you suggested "UBC" was profane in C++ circles? ;-)
John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)


Don't know the book, but this will tell you more about Wheeler:
http://www.usd.edu/phys/courses/phys...k/wheeler.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #39
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}


Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".

This isn't homework, I hope?

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #40
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}


Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".

This isn't homework, I hope?

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #41
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Here's the question. Where (how) does the Holy Standard specify that I
can do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}
Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".


Thanks!
This isn't homework, I hope?

No, it's the first question I asked in this newsgroup. Your response was
along the lines 'one might presume you would find that in the book'. But
you thought I was asking one of the questins you listed previously in this
thread. ;-)
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #42
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Here's the question. Where (how) does the Holy Standard specify that I
can do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}
Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".


Thanks!
This isn't homework, I hope?

No, it's the first question I asked in this newsgroup. Your response was
along the lines 'one might presume you would find that in the book'. But
you thought I was asking one of the questins you listed previously in this
thread. ;-)
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #43
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote

[more snipping than you can shake a stick at]

Here's the question. Where (how) does the Holy Standard
specify that I can do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}


8.5 (Initializers):

initializer:
= initializer clause
( expression-list )

.... and so on.

Claudio Puviani
Jul 22 '05 #44
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote

[more snipping than you can shake a stick at]

Here's the question. Where (how) does the Holy Standard
specify that I can do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}


8.5 (Initializers):

initializer:
= initializer clause
( expression-list )

.... and so on.

Claudio Puviani
Jul 22 '05 #45
* al***@start.no (Alf P. Steinbach) schriebt:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}


Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".


Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.
If the standard were a computer program we'd refactor it. But with the
standard that would probably break too many references.

Now, hope this helps _this_ time...

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #46
* al***@start.no (Alf P. Steinbach) schriebt:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}


Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".


Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.
If the standard were a computer program we'd refactor it. But with the
standard that would probably break too many references.

Now, hope this helps _this_ time...

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #47
On Sun, 04 Apr 2004 15:11:38 GMT, al***@start.no (Alf P. Steinbach) wrote:
Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.


It may be worth noting here that the use of pseudo-constructor syntax on
primitive types is what allows some templates to be written so that they
can be specialized for class /or/ primitive types. I'm not sure whether it
would be totally impossible, or just really ugly, without them.
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #48
On Sun, 04 Apr 2004 15:11:38 GMT, al***@start.no (Alf P. Steinbach) wrote:
Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.


It may be worth noting here that the use of pseudo-constructor syntax on
primitive types is what allows some templates to be written so that they
can be specialized for class /or/ primitive types. I'm not sure whether it
would be totally impossible, or just really ugly, without them.
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #49
Alf P. Steinbach wrote:
Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.
If the standard were a computer program we'd refactor it. But with the
standard that would probably break too many references.
I was wondering what a spaghetti diagram might look like. The Standard is
organized in a hierarchical structure using symbols such as [basic],
[basic.def],[basic.def.odr], etc.

http://www.itga.com.au/~gnb/wp/cd2/

There are extensive crossreferences pointing to different sections. I
wonder what it would look like if someone tried to pin it all up on a huge
tack board with lines connecting the references. Could it be treated as a
collection of objects in some kind of (pseudo-) UML diagram? It might also
be instructive to include the grammar in this spaghetti diagram.

Another thing that might be useful is a hyperlinked version of the Grammar
which took the user to discussion in the text, and/or examples using the
particular derivation.
Now, hope this helps _this_ time...


I'll have to review it all. Parts of the Standard are very hard to read
because they have a lot of forward references (if that's the proper term
for things mentioned but not yet defined). Other parts are easier to read
than TC++PL(SE) discussion of the same topic. I'm currently trying to slog
my way through Clause(?) 3 [basic]. The whole 'chapter'.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: john sun | last post by:
Hi, I have a class with copy ctor and assignment operator. MyClasss obj1(data); MyClass obj2=obj1; in this case, the copy constructor is invoked instead of assignment operator. I cannot...
47
by: Charles Stapleton | last post by:
Given the folowing class class Ctest{ public: Ctest( int i, int j) :a(i) { b = j; } private: int a, b; } When creating an object of type Ctest, what advantage is there to setting
17
by: Thomas Lorenz | last post by:
Hello, I'm a little confused about object initialization. According to Stroustrup (The C++ Programming Language, Special Edition, Section 10.2.3) constructor arguments should be supplied in one...
6
by: Neil Zanella | last post by:
Hello, I would like to know whether the following C fragment is legal in standard C and behaves as intended under conforming implementations... union foo { char c; double d; };
7
by: skishorev | last post by:
What is the difference between copy initialization and assignment. How the memory will allocates the objects. Thanks &regards, Sai Kishore
8
by: lovecreatesbea... | last post by:
K&R 2, sec 2.4 says: If the variable in question is not automatic, the initialization is done once only, conceptually before the program starts executing, ... . "Non-automatic variables are...
11
by: asdf | last post by:
The oder of member initialization is the order in which the members are defined. So the following code is problematic: class X{ int i; int j; public: X(int val):j(val),i(j){}
23
by: Jess | last post by:
Hello, I understand the default-initialization happens if we don't initialize an object explicitly. I think for an object of a class type, the value is determined by the constructor, and for...
2
by: timlyee | last post by:
int *p = new int; auto_ptr<intap1 = p; //will fail on 3 1 auto_ptr<intap1(p); //ok 2 *ap1 = 12; // 3 the first situation has called :...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.