C++ typedef 两种用法

typedef unsigned char BYTE;
BYTE b1;

#include<iostream>
typedef class APrinterClass {
public:
	void printer()
	{
		std::cout << "Print this" << std::endl;
	}
} APrinter;
 

int main()
{
	APrinter obj;
	obj.printer();
	return 0;
}

总结,

  1. typedef可以定义新的变量类型
  2. typedef也可以用于定义一个新的类,作为一种新的变量类型
原文地址:https://www.cnblogs.com/yaos/p/14014200.html