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


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

Re: How to "fake" a member initialization?

From Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt>
Newsgroups comp.lang.c++
Subject Re: How to "fake" a member initialization?
Date 2020-01-13 20:32 +0000
Organization Aioe.org NNTP Server
Message-ID <qvik43$8ki$1@gioia.aioe.org> (permalink)
References <qvieas$1dah$1@gioia.aioe.org>

Show all headers | View raw


Às 18:53 de 13/01/20, Paulo da Silva escreveu:
> Hi all!
> 
> I have a member whose structure I don't know.
> I don't need it to be initialized but the compiler warns me of that.
> "Member 'foo' was not initialized in this constructor".
> 
> Is there a way to tell the compiler that I don't want that member to be
> initialized?
> 

From the answers so far, may be I didn't explain my problem very well :(

The main point is that I have a member (a var) which I don't want to
initialize in the constructor. So, the compiler warns me of that.
What is the best practice to "clean" that warning message for that
particular member?

Not important, btw, the reasons I don't want to initialize it are:
1. It is not needed;
2. That member is an external structure that depends on the OS.

I could do for example:
memset((void *)&foo,0,sizeof(foo));
or, better
memset((void *)&foo,0,0);
1. How do I do this, in a more c++ way?
2. Is there a better way to fool the compiler without doing anything?

Thanks.

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


Thread

How to "fake" a member initialization? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2020-01-13 18:53 +0000
  Re: How to "fake" a member initialization? Öö Tiib <ootiib@hot.ee> - 2020-01-13 11:08 -0800
  Re: How to "fake" a member initialization? Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-13 20:12 +0100
  Re: How to "fake" a member initialization? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-13 20:15 +0000
  Re: How to "fake" a member initialization? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2020-01-13 20:32 +0000
    Re: How to "fake" a member initialization? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-13 20:36 +0000
      Re: How to "fake" a member initialization? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2020-01-13 20:59 +0000
        Re: How to "fake" a member initialization? Melzzzzz <Melzzzzz@zzzzz.com> - 2020-01-13 21:29 +0000
        Re: How to "fake" a member initialization? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-13 21:45 +0000
          Re: How to "fake" a member initialization? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2020-01-14 01:04 +0000
    Re: How to "fake" a member initialization? Melzzzzz <Melzzzzz@zzzzz.com> - 2020-01-13 21:28 +0000
  Re: How to "fake" a member initialization? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-01-13 23:23 +0100
  Re: How to "fake" a member initialization? Frederick Gotham <cauldwell.thomas@gmail.com> - 2020-01-14 00:34 -0800
    Re: How to "fake" a member initialization? Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2020-01-14 15:33 +0000

csiph-web