Thread: A really stupid question about struct constructors

  1. #1
    Registered User
    Join Date
    Jan 2010

    Red face A really stupid question about struct constructors

    Hi there,

    Idk why but this has got me worried. I've had to make a change to a function written by someone else as it won't compile in conformance mode. It was throwing the good old C2102 error

        //&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT), - will not compile in conformance mode 20/3/24
    It works now but I'm unsure if I made the heap property variable correctly. I should know this really, but I seemed to have wandered into a self-doubt spell so I'd like to check.

    So will this line of code create the heap properties struct named heapProperties with the correct constructor, just as the function parameter originally did?

    That's all, thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAUL T) creates a temporary object.

    The main problem with these is you've got no control over the lifetime of the temporary, which is why it now complains.

    So yeah, your fix is good.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Great, thanks very much Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simplifying constructors in struct
    By c_weed in forum C++ Programming
    Replies: 7
    Last Post: 12-09-2010, 04:48 PM
  2. Question about Constructors
    By Jefff in forum C++ Programming
    Replies: 8
    Last Post: 07-28-2009, 02:24 PM
  3. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM
  4. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  5. Stupid Math Question....really stupid
    By ToLazytoSignIn in forum A Brief History of
    Replies: 9
    Last Post: 01-16-2003, 07:36 PM

Tags for this Thread