Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

1 + 1 = 3, for large values of 1.


devel / comp.lang.c++ / Re: a problem with an program

SubjectAuthor
* Re: a problem with an programBen Bacarisse
`* Re: a problem with an programAlf P. Steinbach
 +- Re: a problem with an programBen Bacarisse
 `- Re: a problem with an programBen Bacarisse

1
Re: a problem with an program

<87v8bsagai.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2000&group=comp.lang.c%2B%2B#2000

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: a problem with an program
Date: Fri, 29 Sep 2023 21:13:57 +0100
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <87v8bsagai.fsf@bsb.me.uk>
References: <fbfd5e3e-ccff-470d-b2b4-7090c1649e6an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4dfdf850a714e5d3717da460fbf945f6";
logging-data="472823"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aG54FDdb8jH+adMZXBMHu+CF3Rza//tU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:+mFNpP+JrmV4Jn7yPFofcH+NmlQ=
sha1:VOvfqFRiHuD46JOwwT6bO9noVOo=
X-BSB-Auth: 1.463e0ac91d35c17b762e.20230929211357BST.87v8bsagai.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 29 Sep 2023 20:13 UTC

karam hello <karamhello2@gmail.com> writes:

> i have a problem with this program using C++ OOP inheritance
> specially on class c:

Your compiler should be telling your what's wrong. It might not do so
very clearly, but it should be pointing you to where the problem is.

But let me play compiler here and give you a different error message...

> #include <iostream>
> using namespace std;
> class a{
> private:
> string name;
> int age;
> public:
> a(string n, int a){
> name = n;
> age = a;
> }
> };
> class b{
> private:
> string email;
> public:
> b(string em){
> email = em;
> }
> };
> class c:public a, public b{
> public:
> c(string n, int a, string em) : a(n, a), b(em){}
line 23 position 41 ______________________^
a is an int. I can't call a(n, a) when a is an int.

> };
> int main(){
> c c1("k", 10, "com");
> }

Does that help?

--
Ben.

Re: a problem with an program

<ufbu2m$1j79g$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2027&group=comp.lang.c%2B%2B#2027

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.steinbach@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Re: a problem with an program
Date: Sun, 1 Oct 2023 16:00:54 +0200
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <ufbu2m$1j79g$1@dont-email.me>
References: <fbfd5e3e-ccff-470d-b2b4-7090c1649e6an@googlegroups.com>
<87v8bsagai.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 1 Oct 2023 14:00:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3ef240dc9cbcc34a61d999825cdc7c6a";
logging-data="1678640"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cldaXR2/QOnJyndivKLm4"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:3C7NgazHHcjjAhAGdZgq9fpZrsM=
In-Reply-To: <87v8bsagai.fsf@bsb.me.uk>
Content-Language: en-US
 by: Alf P. Steinbach - Sun, 1 Oct 2023 14:00 UTC

On 2023-09-29 10:13 PM, Ben Bacarisse wrote:
> karam hello <karamhello2@gmail.com> writes:
>
>> i have a problem with this program using C++ OOP inheritance
>> specially on class c:
>
> Your compiler should be telling your what's wrong. It might not do so
> very clearly, but it should be pointing you to where the problem is.
>
> But let me play compiler here and give you a different error message...
>
>> #include <iostream>
>> using namespace std;
>> class a{
>> private:
>> string name;
>> int age;
>> public:
>> a(string n, int a){
>> name = n;
>> age = a;
>> }
>> };
>> class b{
>> private:
>> string email;
>> public:
>> b(string em){
>> email = em;
>> }
>> };
>> class c:public a, public b{
>> public:
>> c(string n, int a, string em) : a(n, a), b(em){}
> line 23 position 41 ______________________^
> a is an int. I can't call a(n, a) when a is an int.
>
>> };
>> int main(){
>> c c1("k", 10, "com");
>> }
>
> Does that help?

g++ complains about that thing, but Visual C++ compiles the code just
fine as C++17.

Sort of, Visual C++ is consistent (base classes treated the same as data
members), while g++ is conforming. They're both "con". Just differently.

I guess learning point is, to be both consistent and conforming never
choose the same name for a constructor parameter and sub-object.

- Alf

Re: a problem with an program

<87a5t2cqeh.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2028&group=comp.lang.c%2B%2B#2028

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: a problem with an program
Date: Sun, 01 Oct 2023 16:29:26 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <87a5t2cqeh.fsf@bsb.me.uk>
References: <fbfd5e3e-ccff-470d-b2b4-7090c1649e6an@googlegroups.com>
<87v8bsagai.fsf@bsb.me.uk> <ufbu2m$1j79g$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="c2f22c1fb3b550915037b7b8f30f30b7";
logging-data="1713949"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EouL4cVGP16vNSnGU12ypDZ45havDHvY="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:5LYY/Z7z//rwhLBqjCFUpHBA10M=
sha1:n3l3LQBg+qWEd8bCSgObGyhjMoc=
X-BSB-Auth: 1.8f0d701bad183ac11984.20231001162926BST.87a5t2cqeh.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 1 Oct 2023 15:29 UTC

"Alf P. Steinbach" <alf.p.steinbach@gmail.com> writes:

> On 2023-09-29 10:13 PM, Ben Bacarisse wrote:
>> karam hello <karamhello2@gmail.com> writes:
>>
>>> i have a problem with this program using C++ OOP inheritance
>>> specially on class c:
>> Your compiler should be telling your what's wrong. It might not do so
>> very clearly, but it should be pointing you to where the problem is.
>> But let me play compiler here and give you a different error message...
>>
>>> #include <iostream>
>>> using namespace std;
>>> class a{
>>> private:
>>> string name;
>>> int age;
>>> public:
>>> a(string n, int a){
>>> name = n;
>>> age = a;
>>> }
>>> };
>>> class b{
>>> private:
>>> string email;
>>> public:
>>> b(string em){
>>> email = em;
>>> }
>>> };
>>> class c:public a, public b{
>>> public:
>>> c(string n, int a, string em) : a(n, a), b(em){}
>> line 23 position 41 ______________________^
>> a is an int. I can't call a(n, a) when a is an int.
>>
>>> };
>>> int main(){
>>> c c1("k", 10, "com");
>>> }
>> Does that help?
>
> g++ complains about that thing, but Visual C++ compiles the code just fine
> as C++17.

Curious. Which one is correct? Without studying the standard, I would
have thought that gcc has it right.

--
Ben.

Re: a problem with an program

<87edibb3y6.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2063&group=comp.lang.c%2B%2B#2063

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: a problem with an program
Date: Wed, 04 Oct 2023 01:56:33 +0100
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <87edibb3y6.fsf@bsb.me.uk>
References: <fbfd5e3e-ccff-470d-b2b4-7090c1649e6an@googlegroups.com>
<87v8bsagai.fsf@bsb.me.uk> <ufbu2m$1j79g$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="481e03f615ddba580c389ef61c27c899";
logging-data="4017295"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nYqjbcm38T148xN3qu3fw0JbmRS2ka8Y="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:NO+a74Y8DFZEqvJGb4fVOxohz/Q=
sha1:lsRuyKapARmTuutfF2qD1wd0N0k=
X-BSB-Auth: 1.28f424dc08ef0c9c116f.20231004015633BST.87edibb3y6.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 4 Oct 2023 00:56 UTC

"Alf P. Steinbach" <alf.p.steinbach@gmail.com> writes:

> On 2023-09-29 10:13 PM, Ben Bacarisse wrote:
>> karam hello <karamhello2@gmail.com> writes:
>>
>>> i have a problem with this program using C++ OOP inheritance
>>> specially on class c:
>> Your compiler should be telling your what's wrong. It might not do so
>> very clearly, but it should be pointing you to where the problem is.
>> But let me play compiler here and give you a different error message...
>>
>>> #include <iostream>
>>> using namespace std;
>>> class a{
>>> private:
>>> string name;
>>> int age;
>>> public:
>>> a(string n, int a){
>>> name = n;
>>> age = a;
>>> }
>>> };
>>> class b{
>>> private:
>>> string email;
>>> public:
>>> b(string em){
>>> email = em;
>>> }
>>> };
>>> class c:public a, public b{
>>> public:
>>> c(string n, int a, string em) : a(n, a), b(em){}
>> line 23 position 41 ______________________^
>> a is an int. I can't call a(n, a) when a is an int.
>>
>>> };
>>> int main(){
>>> c c1("k", 10, "com");
>>> }
>> Does that help?
>
> g++ complains about that thing, but Visual C++ compiles the code just fine
> as C++17.

Curious. Which one is correct I wonder.

--
Ben.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor