Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #92252

Re: a problem with an program

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c++
Subject Re: a problem with an program
Date 2023-09-29 21:13 +0100
Organization A noiseless patient Spider
Message-ID <87v8bsagai.fsf@bsb.me.uk> (permalink)
References <fbfd5e3e-ccff-470d-b2b4-7090c1649e6an@googlegroups.com>

Show all headers | View raw


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.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

a problem with an program karam hello <karamhello2@gmail.com> - 2023-09-29 12:59 -0700
  Re: a problem with an program Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-09-29 21:13 +0100
    Re: a problem with an program "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-10-01 16:00 +0200
      Re: a problem with an program Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-01 16:29 +0100
      Re: a problem with an program Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-04 01:56 +0100
  Re: a problem with an program David Brown <david.brown@hesbynett.no> - 2023-09-30 16:57 +0200

csiph-web