AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

C++ = C++ ?

Ein Thema von ebber · begonnen am 11. Apr 2007 · letzter Beitrag vom 20. Feb 2008
Antwort Antwort
OregonGhost

Registriert seit: 8. Jun 2002
Ort: Lübeck
1.216 Beiträge
 
Delphi 3 Professional
 
#1

Re: C++ = C++ ?

  Alt 20. Feb 2008, 16:22
Nein, das stimmt nicht. Und selbst wenn der Standard es vorschreiben würde, würde jeder Compiler es wegoptimieren.

Zitat von IBM:
You explicitly initialize a class object when you create that object. There are two ways to initialize a class object:

* Using a parenthesized expression list. The compiler calls the constructor of the class using this list as the constructor's argument list.
* Using a single initialization value and the = operator. Because this type of expression is an initialization, not an assignment, the assignment operator function, if one exists, is not called. The type of the single argument must match the type of the first argument to the constructor. If the constructor has remaining arguments, these arguments must have default values.
Ich bleibe bedauerlicherweise ein Zitat aus dem ISO-Standard schuldig. Den kann man einfach nicht lesen. Jedenfalls sagt der Sprachstandard das gleiche aus, nur in etwa zwanzigmal so viel Zeilen und auf eine Art und Weise, die man sowieso nicht versteht
Aber es sagt genau das:
Code:
int i = 0;
ist keine Zuweisung, sondern eine Initialisierung und damit erfolgt genau ein Konstruktoraufruf.

Edit:
Das Zitat oben stammt aus der Dokumentation zu einem der IBM-C++-Compiler. Ich kann dir aber versichern, dass auch z.B. Visual C++ und der GCC sich genau so verhalten, und dass sie es nicht tun, weil sie einfach nur gut optimieren.
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:35 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz