Can I write type converters for a custom class?

조회 수: 2 (최근 30일)
Hau Kit Yong
Hau Kit Yong 2019년 4월 23일
I want to write a method in my custom classes to return string representations of instantiated objects (similar to writing a "__str__" method in Python), to allow calls such as sprintf('%s', object). The next best solution is to just write a "toString" method for each of my classes, but of course I would have to maintain that function name for all my classes to make the code usable. I appreciate any other ideas.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by