2

Here is the code I am concerned with:

double first(2), second(first);

Will the first variable always be initialized before a second one?

  • Why do you care? What's the problem? – Jesper Juhl Sep 02 '17 at 17:49
  • 3
    If you're that concerned, why not just put the declarations on separate lines? – KABoissonneault Sep 02 '17 at 17:49
  • I don't C C here! Why do you tag unrelated languages? – Antti Haapala -- Слава Україні Sep 02 '17 at 17:49
  • 2
    I hope the answers to this question cite the relevant parts of the language specification. – MikeB Sep 02 '17 at 17:52
  • 1
    @JesperJuhl, I am learning C/C++ and I consider an understanding of such fundamental questions to be a vital part of knowing the language. –  Sep 02 '17 at 17:59
  • @AnttiHaapala, why don`t you see a C language here? Is not it possible to initialize a variable in C in such a way? –  Sep 02 '17 at 17:59
  • 1
    @KABoissonneault, I would like to know what is under hood in the case, since I am gonna use a lot of initializations during my C/C++ exploitation. –  Sep 02 '17 at 18:01
  • @ЯрикТроф Not with that particular syntax, I dont do C but when I put it in the online compiler it wouldnt accept it, but it did accept: `double first = 2, second = first;` – Borgleader Sep 02 '17 at 18:01
  • @Borgleader, so is there no such a way to initialize a variable in C? –  Sep 02 '17 at 18:03
  • 2
    @ЯрикТроф you're using **C++ constructor initialization**. And C and C++ are very much distinct languages. – Antti Haapala -- Слава Україні Sep 02 '17 at 18:05
  • 2
    @ЯрикТроф: I'm of the opinion that if you know the answer to this question, then you know entirely *too much* about C++. Remember: people will read your code far more than you will write it. Making it clear and idiot-proof is more important than knowing dark, esoteric corners of the language. – Nicol Bolas Sep 02 '17 at 18:06
  • @AnttiHaapala, thank you very much for the attention! –  Sep 02 '17 at 18:24
  • @NicolBolas, thank you very much for the attention! –  Sep 02 '17 at 18:25
  • @AnttiHaapala, but still. What is an answer to my question? –  Sep 02 '17 at 18:26

0 Answers0