公共純虛成員函式
<system_error>

std::error_category::name

virtual const char* name() const noexcept = 0;
返回類別名稱
在派生類中,該函式返回一個C風格字串,命名該類別。

error_category中,它是一個純虛成員函式。

generic_category 物件中,它返回 "generic"
system_category 物件中,它返回 "system"
iostream_category 物件中,它返回 "iostream"

引數



返回值

指向以空字元結尾的字元序列的第一個字元的指標,其中包含類別名稱

示例

1
2
3
4
5
6
7
8
9
// error_category::name
#include <iostream>       // std::cout
#include <system_error>   // std::error_code

int main() {
  std::error_code ec;	// the default error code is system error 0
  std::cout << ec.category().name() << '\n';
  return 0;
}

輸出
system


另見