c++ - How can I define a function that takes as a parameter a pointer value of any kind? -


I am implementing a smart pointer class practice.

I have already defined the assignment operator overload, taking one more example of the same class. Now I want to define the surcharge of this operator, which takes any indicator. That's why I got the smartPointer = & amp; SomeObject; or smartPointer = NULL; , etc.

How can I do that? Do I pass in void * ? Some more questions?

As another general question (and I know that it is rarely desired): What type of parameter tells the compiler that any indicators can be passed?

Using a template function to allow you to assign your object to a pointer Can.

  template & lt; Type name T & gt; Zero operator = (T * oBJ) {// your code here}   

However, this is not a smart pointer if you can provide it as any raw pointers because it There will be one problem with more than one smart pointer object and then deleting the pointer.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -