Was bedeutet diese C Zeile

Gast #1274696
Lesenswert?

böse, böse, böse ...

ich mag sowas nicht. Vor allem wenn es in macros verwendet wird und 
diese sich dann schachteln. nach 5 Fragezeichen im macro (preprozessor 
output) sieht man überhaupt nicht mehr durch. Und solchen Code musste 
ich mal auf fehler überprüfen.

Ist nett wenn es sehr einfach gehalten ist und sofort einsehbar, aber 
if/else ist auch nicht soviel länger.

JL
Gast #1274732
Lesenswert?

Ich sach dazu nur: Es leben die C++-Templates, sie leben hoch:
1
    d:\src\cl\demo>c++2 rtmap.cpp
2
    rtmap.cpp: In function `int main()':
3
    rtmap.cpp:19: invalid conversion from `int' to `
4
       std::_Rb_tree_node<std::pair<const int, double> >*'
5
    rtmap.cpp:19:   initializing argument 1 of `std::_Rb_tree_iterator<_Val, _Ref,
6
       _Ptr>::_Rb_tree_iterator(std::_Rb_tree_node<_Val>*) [with _Val =
7
       std::pair<const int, double>, _Ref = std::pair<const int, double>&, _Ptr =
8
       std::pair<const int, double>*]'
9
    rtmap.cpp:20: invalid conversion from `int' to `
10
       std::_Rb_tree_node<std::pair<const int, double> >*'
11
    rtmap.cpp:20:   initializing argument 1 of `std::_Rb_tree_iterator<_Val, _Ref,
12
       _Ptr>::_Rb_tree_iterator(std::_Rb_tree_node<_Val>*) [with _Val =
13
       std::pair<const int, double>, _Ref = std::pair<const int, double>&, _Ptr =
14
       std::pair<const int, double>*]'
15
    E:/GCC3/include/c++/3.2/bits/stl_tree.h: In member function `void
16
       std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::insert_unique(_II,
17

18
       _II) [with _InputIterator = int, _Key = int, _Val = std::pair<const int,
19
       double>, _KeyOfValue = std::_Select1st<std::pair<const int, double> >,
20
       _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int,
21
       double> >]':
http://www.bdsoft.com/tools/stlfilt.html
Gast #1275597
Lesenswert?

>ucFCWrite = ((urFlow & UI_FLOW_MASK) ? X_TRUE : X_FALSE);

>ich verstehe eigentlich folgendes nicht:

>? X_TRUE : X_FALSE);
>-----------------------------------------------------------------
>Das ist eine verkürzte Schreibweise für

>if(urFlow & UI_FLOW_MASK)
>  X_TRUE;
>else
>  X_FALSE;


if urFlow & UI_FLOW_MASK then
  ...
else
  ...
end if


Was liest sich angenehmer?  Ein Compiler macht das gleiche draus!

das böse Basic!
Gast #1275769
Lesenswert?

<offtopic>

Jaja, geh du mit deinem Basic erstmal Array und Vektoren durch.
1
dim x, y
2
x = EineFunktion(3)
3
y = EinVektor(3) 'Na, was verwechselt sich besser?

Soviel zum pösen Basic.

Wer bei so simplen Sachen wie dem IF in C schon mit Basic und andren 
vergleicht und meint, die anderen ließen sich leichter lesen... sorry, 
der soll bitte wieder in den Kindergarten und die Finger vom 
Programmieren lassen.
#1275864
Lesenswert?

Z8 schrieb:

> Was liest sich angenehmer?  Ein Compiler macht das gleiche draus!

Das hier
1
  DrawItem( x, y,
2
            Background   == DoDraw ? Opaque : Transparent,
3
            Color        == White  ? Black : Color,
4
            Item->type() == Line   ? DrawCaps : DrawStraight );

liest sich um einiges angenehmer als

1
  drawFlag tempFlag = Opaque;
2
  if( Background == DoDraw )
3
    tempFlag = Transparent;
4

5
  color tmpColor = Color;
6
  if( Color == White )
7
    tmpColor = Black;
8

9
  endType tmpType = DrawCaps;
10
  if( Item->type() == Line )
11
    tmpType = DrawStraight;
12

13
  DrawItem( x, y, tmpFlag, tmpColor, tmpType );

oder gar, Gott bewahre, eine geschachtelte if-then-else Leiste.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren