Just as the declaraion float x = 1.0f
is valid and the suffix f
tells the compiler that it should treat the characters between it and the equal sign as a float, is there any way we can define our own suffixes for classes we implement? Say, for example, you have the class
class CustomString
{
string part1;
string part2;
}
and you want to use the code
CustomString Test = abc.defX
where X
is the suffix to tell the compiler to initialize part1
with "abc"
and part2
with "def"
? Of course something like this must be built over a constructor, but I am really interested only in the suffix-definition part.
不,没有办法做到这一点。
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.