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


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

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:59 +0000
Organization Aioe.org NNTP Server
Message-ID <qvilns$fml$1@gioia.aioe.org> (permalink)
References <qvieas$1dah$1@gioia.aioe.org> <qvik43$8ki$1@gioia.aioe.org> <slrnr1pl5h.km3.grahn+nntp@frailea.sa.invalid>

Show all headers | View raw


Às 20:36 de 13/01/20, Jorgen Grahn escreveu:
> On Mon, 2020-01-13, Paulo da Silva wrote:
>> À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 :(
> 
> What was wrong with my answer?
> 
Sorry, I hadn't seen your answer when I posted.

Now that I have read it ...

About the compiler: It's g++ and all options are appropriate for the
rest of the project.

I have this code:
Dir::Dir(): cur_entryp(0),vec(0)
{
	// memset((void *)&cur_dev,0,sizeof(cur_dev)); // OK
	// memset((void *)&cur_dev,0,0); // OK and do nothing.
	cur_dev={}; // OK

	... other init stuff ...

}

The member I am talking about is cur_dev.
cur_dev={} also works (no warning)!
Does this cause any code to be executed?
Is it the best way in c++?

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