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


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

Re: a problem with an program

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c++
Subject Re: a problem with an program
Date 2023-09-30 16:57 +0200
Organization A noiseless patient Spider
Message-ID <uf9d08$uldu$1@dont-email.me> (permalink)
References <fbfd5e3e-ccff-470d-b2b4-7090c1649e6an@googlegroups.com>

Show all headers | View raw


On 29/09/2023 21:59, karam hello wrote:
>   i have a problem with this program using C++ OOP inheritance specially on class c:
> #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){}
> };
> int main(){
>      c c1("k", 10, "com");
> }

It looks like you are learning the language.  I recommend getting in the 
habit of using good names for your classes (and everything else), rather 
than "a" or "b".  Good naming makes code easier to write, and vastly 
easier to read, and you should practice it from the start, even for 
simple test code.  See if it helps you out here.

Back to comp.lang.c++ | Previous | Next — Previous 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