Is that possible to replace two similar member functions with a template function?

For example

class A {
   void fun(Array a);
   void fun(Vector a);
   /* Most codes in these two functions are same. */
   /* Can certainly be merged into a template function if they were not member functions. */

Please note that I hope to have both these two versions of fun() in class A. Thanks.


Even if the class is not templated itself you can write a member function that is templated in the same manner that you would write a templated function that was not a method of a class.

template <class myType >
myType func (myType a) {
 /* do something */;

Need Your Help

Create website with a page to show online users including username and picture

php mysql database website social-networking

I am in the stages of the class diagram, I was creating the class diagram for a website I am planning to create. It was going fine until I reached the stage of wanting to have a web page that displ...

Android Specific Gradle product flavor combinations

android gradle

In my code I have certain templates all deriving from one code base. For each template I want to add specific dimensions. Using flavor dimensions and product flavors I have reached this code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.