In Go, if the type has all the methods that the interface defined then it can be assigned to that interface variable without explicitly inheriting from it.
Is it possible to mimic this feature in C/C++?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. You can use a pure abstract class, and use a template class to wrap types “implementing” the abstract class so that they extend the abstract class. Here’s a barebones example: