.


:




:

































 

 

 

 


.




:

int rdstate()-

int eof()- , eofbit

int fail()- , failbit,badbit hardbit

int bad()- , badbit hardbit

int good()- ,

void clear(int i=0)- , 0;

operator void*()- ,

operator!()- ,

//, flag

if(stream_obj.rdstate() & ios::flag)

// flag

stream_obj.clear(rdstate() &~ ios::flag)

// flag

stream_obj.clear(rdstate() │ ios::flag)

// flag

stream_obj.clear(ios::flag)

//

stream_obj.clear()

void*() , 0. :

while(stream_obj){

// /}

ios state :

enum io_state{

goodbit =0x00.//

eofbit=0x01.//

failbit=0x02.//

badbit=0x04.// ,

hardfail=0x08.//

};

 


43. ++. -. , . .

- : , . ios .

<< >> cout, cin, cerr, clog '''' .

. ios. protected long x_flags. public .

protected ios:

int x_width - .

int x_precision - ( ) ;

int x_fill - - , - .

() :

int width(void);int width(int);int precision(void);int precision(int);char fill(void);char fill(char);

-. : width(), precision() fill().

, . width() . . , , - ( - ). , , . :

int width(int wide);
int width() const;

wide, . . , . , .

precision() ( ), . , . precision () :

int precision(int prec);
int precision() const;

prec . .

fill() -. :

char fill(char type ch);
char fill() const;

ch - -. -. - .

, . , ios .

ios, . .

, . , >> <<. , , ( ), . , , , ..

istream ostream operator.

istream &operator >>(istream &(*_f)(istream &));ostream &operator <<(ostream &(*_f)(ostream &));

<iomanip.h>, . - .

 

dec 10- . int long.
  10 .
hex 16- .
oct 8- .
ws .
  , ,
  .
endl .
ends '\0' .
flush .

setbase() :

  . 10-, - ,
  '0', 8-, '0x',
  - 16-. 10-.
  - 8.
  - 10.
  - 16.

44. ++

( ).

template< >

_(...)

{

//

}

:

class

template<class T>

void Swap(T t[], int i1, int i2)

{

T tmp=t[i1];

t[i1]=t[i2];

t[i2]=tmp;

}

// 2

template<class T>

void f1(T t1, T t2) {...}

// 2

template<class T1, class T2>

void f2(T1 t1, T2 t2) {...}

:

template<class T>

void Sort(T arr1, int size)

{

for(int i=0,i<size-1;i++)

{

for(j=0,i<j;j--)

{

if(arr[j-1]>arr[i])

{

T tmp=arr[j];

arr[j]=arr[j-1];

arr[j-1]=tmp;

}

}

}

}

>.

. . , . . , .

template<class T>

void Sort(T arr1, int size);

, .

#include <iostream.h>

#include sort_template

int main()

{

int A={1,2,5,4,3,8};

int size=sizeof();

} , .

class Time

{

int hour, minutes;

public:

Time(int h, int m){hour=h;minutes=m};

int operator>(const Time &t) const

{

return((hour>t.hour)||hour==t.hour && minutes==t.minutes)

}

}

int main()

{

TimeArray[]={Time(12,15), Time(11,30), Time(02,50)};

int size=(sizeof(TimeArray[])/sizeof(TimeArray[0]));

...}

, . .. . .





:


: 2016-07-29; !; : 847 |


:

:

, ,
==> ...

1292 - | 1273 -


© 2015-2024 lektsii.org - -

: 0.023 .