Hi I am trying to use counted_ptr with a class.
Can anyone tell me about the syntax and how to use it.
I tried as below but failed.

    class counted_ptr ;
    counted_ptr<MyClass>pmyClass= NULL;

counted_ptr isn't a standard class, which means you're trying to use a third party class. Where did you get it? How you use it greatly depends on how it was written to be used.

counted_ptr must be a template/generic type which is well designed.

template<class T>
count_ptr{
  count_ptr():t(tp){}
  operator()(){}
  operator +(){}
  operator=(){}
private:
  T t;
};

int main(){
//class foo object  bar
foo bar;

// now count_ptr serves as a container that can accept and manipulate class 
//foo objects.
count_ptr<bar> count_ptr_bar.


}

get back to the basis of generics.
send from my phone so its not a working code. just the righ path.

Need to declare a Counted_ptr of a class.
Can I get an example regarding how to declare it and then initialize it to NULL

Can I get an example regarding how to declare it and then initialize it to NULL

Sure, once you answer my question. I can't tell you how to use some random class that I'm not familiar with, but given either the class itself or sufficient documentation I'll be happy to help out.

Are you trying to use a shared_pointer which has a count of how many objects hold the pointer?

I quick google search reveals that counted_ptr is a pre-historic version of shared_ptr. Unless you are using a specific (old) library that requires the use of counted_ptr, I must say that you should prefer using the standard std::shared_ptr pointer, or it's equivalent in Boost boost::shared_ptr.