АвтоАвтоматизацияАрхитектураАстрономияАудитБиологияБухгалтерияВоенное делоГенетикаГеографияГеологияГосударствоДомДругоеЖурналистика и СМИИзобретательствоИностранные языкиИнформатикаИскусствоИсторияКомпьютерыКулинарияКультураЛексикологияЛитератураЛогикаМаркетингМатематикаМашиностроениеМедицинаМенеджментМеталлы и СваркаМеханикаМузыкаНаселениеОбразованиеОхрана безопасности жизниОхрана ТрудаПедагогикаПолитикаПравоПриборостроениеПрограммированиеПроизводствоПромышленностьПсихологияРадиоРегилияСвязьСоциологияСпортСтандартизацияСтроительствоТехнологииТорговляТуризмФизикаФизиологияФилософияФинансыХимияХозяйствоЦеннообразованиеЧерчениеЭкологияЭконометрикаЭкономикаЭлектроникаЮриспунденкция

Потоки ввода-вывода

Читайте также:
  1. Глава 2. Линии или Потоки Развития
  2. Глава 4. Потоки самосознания
  3. Денежные потоки, генерируемые производственной, инвестиционной и финансовой деятельностью предприятия
  4. Информационная модель организации. Инфомационные потоки. Виды информационных моделей
  5. Информационные потоки и их виды
  6. ЛИНИИ ИЛИ ПОТОКИ РАЗВИТИЯ
  7. Макроэкономические модели. Экзогенные и эндогенные переменные. Запасы и потоки.
  8. Потоки платежей. Ренты.
  9. ПОТОКИ САМОСОЗНАНИЯ
  10. Потоки энергии и круговорот вещества в экосистемах.
  11. Расширения (или альтернативные потоки)

 

В языке С++ вместо функций printf и scanf предлагается использовать объекты потоковых классов:

std::cout;

std::cin;

 

Вывод осуществляется с помощью оператора сдвига:

 

std::cout << "Hello!";

int n;

std::cin >> n;

 

Чтобы перевести строку надо сделать следующую запись:

 

std::cout << "Hello!" << std::endl; // или"\n"

 

Объекты cout и cin являются экземплярами классов ostream и istream. Существуют также классы iostream (класс для ввода/вывода) и streambuf (позволяет выполнить буферизованный ввод/вывод).

 

В программе не следует смешивать потоковый ввод/вывод с функциями printf и scanf. Если все же это происходит, То между блоками кода, использующими тот или иной подход, надо выполнять вызов функции fflush – сброс буферов.

 

Деление типов данных на типы-«значения» (value-types) и типы-«ссылки» (reference-types) в языке C#. Автоматическое управление памятью ссылочных данных. Упаковка и разупаковка данных. Типы данных со значением null.

 

Деление типов данных на типы-«значения» (value-types) и типы-«ссылки» (reference-types) в языке C#

The types of the C# language are divided into two main categories: Value types and reference types. Both value types and reference types may be generic types, which take one or more type parameters. A third category of types, pointers, is available only in unsafe code.

 

Value types differ from reference types in that variables of the value types directly contain their data, whereas variables of the reference types store references to their data, the latter being known as objects. With reference types, it is possible for two variables to reference the same object, and thus possible for operations on one variable to affect the object referenced by the other variable. With value types, the variables each have their own copy of the data, and it is not possible for operations on one to affect the other.

 

C#’s type system is unified such that a value of any type can be treated as an object. Every type in C# directly or indirectly derives from the object class type, and object is the ultimate base class of all types. Values of reference types are treated as objects simply by viewing the values as type object. Values of value types are treated as objects by performing boxing and unboxing operations.

 

A value type is either a struct type or an enumeration type. C# provides a set of predefined struct types called the simple types. The simple types are identified through reserved words.

 

value-type:
struct-type
enum-type

struct-type:
type-name
simple-type
nullable-type

simple-type:
numeric-type
bool

numeric-type:
integral-type
floating-point-type
decimal

integral-type:
sbyte
byte
short
ushort
int
uint
long
ulong
char

floating-point-type:
float
double

nullable-type:
non-nullable-value-type

non-nullable-value-type:
type

enum-type:
type-name

Unlike a variable of a reference type, a variable of a value type can contain the value null only if the value type is a nullable type. For every non-nullable value type there is a corresponding nullable value type denoting the same set of values plus the value null.

Assignment to a variable of a value type creates a copy of the value being assigned. This differs from assignment to a variable of a reference type, which copies the reference but not the object identified by the reference.

 

All value types implicitly inherit from the class System.ValueType, which, in turn, inherits from class object. It is not possible for any type to derive from a value type, and value types are thus implicitly sealed. Note that System.ValueType is not itself a value-type. Rather, it is a class-type from which all value-types are automatically derived.

 

A reference type is a class type, an interface type, an array type, or a delegate type.

reference-type:
class-type
interface-type
array-type
delegate-type

class-type:
type-name
object
dynamic
string

interface-type:
type-name

array-type:
non-array-type rank-specifiers

non-array-type:
type

delegate-type:
type-name

A reference type value is a reference to an instance of the type, the latter known as an object. The special value null is compatible with all reference types and indicates the absence of an instance.

 

All value types implicitly declare a public parameterless instance constructor called the default constructor. The default constructor returns a zero-initialized instance known as the default value for the value type:

For all simple-types, the default value is the value produced by a bit pattern of all zeros.

Like any other instance constructor, the default constructor of a value type is invoked using the new operator. For efficiency reasons, this requirement is not intended to actually have the implementation generate a constructor call. In the example below, variables i and j are both initialized to zero.


 

class A
{
void F()

{
int i = 0;
int j = new int();
}
}

 

The float type can represent values ranging from approximately 1.5 × 10−45 to 3.4 × 1038 with a precision of 7 digits.

The double type can represent values ranging from approximately 5.0 × 10−324 to 1.7 × 10308 with a precision of 15-16 digits.

 

The decimal type is a 128-bit data type suitable for financial and monetary calculations. The decimal type can represent values ranging from 1.0 × 10−28 to approximately 7.9 × 1028 with 28-29 significant digits.

 

The bool type represents boolean logical quantities. The possible values of type bool are true and false. No standard conversions exist between bool and other types. In particular, the bool type is distinct and separate from the integral types, and a bool value cannot be used in place of an integral value, and vice versa.

 

An enumeration type is a distinct type with named constants. Every enumeration type has an underlying type, which must be byte, sbyte, short, ushort, int, uint, long or ulong. The set of values of the enumeration type is the same as the set of values of the underlying type. Values of the enumeration type are not restricted to the values of the named constants.

 

The object class type is the ultimate base class of all other types. Every type in C# directly or indirectly derives from the object class type (System.Object).

 

The dynamic type, like object, can reference any object. When operators are applied to expressions of type dynamic, their resolution is deferred until the program is run. Thus, if the operator cannot legally be applied to the referenced object, no error is given during compilation. Instead an exception will be thrown when resolution of the operator fails at run-time.

 

The string type is a sealed class type that inherits directly from object. Instances of the string class represent Unicode character strings.

 

An interface defines a contract. A class or struct that implements an interface must adhere to its contract. An interface may inherit from multiple base interfaces, and a class or struct may implement multiple interfaces.

 

An array is a data structure that contains zero or more variables which are accessed through computed indices.

 

A delegate is a data structure that refers to one or more methods. For instance methods, it also refers to their corresponding object instances.


1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |

Поиск по сайту:



Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Студалл.Орг (0.005 сек.)