简体   繁体   中英

Wrapper class in C for byte like java Byte,Integer,String,Double?

In Java Byte wrapper classes is there like

byte-Byte
int-Integer
float-Float etc

i want to use wrapper classes in c so anyone let me know how to use wrapper classes in c and how to write this in c??

JAVA:

Byte arr= 0x03;

In C there are no classes at all. You could create a struct with a char member but I'm not really sure why you'd want to do that.

In C++, you could create a wrapper class. You just need to define implicit conversions to and from char to simulate autoboxing, as well as whatever methods you think the wrapper class should have.

Also, the equivalent of the Java 'byte' type in C and C++ is signed char .

In C you write char arr = 0x03; . There are no "wrapppers" or "boxing" for POD types. And you don't really need them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM