0
template <class S> 
    class Price{  
        public:
            
            Price(double p)  :  p_(p)
            {
                check(p);
            }

            Price(const Price<S>& p) : p_(p.p_){}

            double price() const {
            
                return p_;
            }

            Price<S>& operator = (double p) 
            {
                check (p); p_ = p; return *this;
            }

            Price<S>& operator = (const Price<S>& p)
            {
                p_ = p.p; return *this;
            }
        
        private:

Im trying to find an answer on the internet but unfortunately im lost. Cause i dont know how to describe it. thanks in advance

  • Welcome to Stack Overflow. "Im trying to find an answer on the internet but unfortunately im lost. Cause i dont know how to describe it." - unfortunately, that is not considered our problem here - we [require specific, clear](https://meta.stackoverflow.com/questions/284236/) questions, and it is [considered your responsibility](https://meta.stackoverflow.com/questions/261592) to look for them first. We [cannot simply explain](https://meta.stackoverflow.com/questions/253894) code, because there is no way we can know what to tell you - we don't know **why** you don't understand it. – Karl Knechtel Nov 30 '22 at 20:47
  • Thanks Karl I didn't see it. :) – unknwnMod Nov 30 '22 at 20:47
  • 1
    There is nothing special about it being a template here. If `Price` was just a non-templated class, would you still ask about `Price& operator = (const Price& p)`? You should be learning about templates way after learning about overloading `operator=`. So it is a bit confusing why you are asking here about the template. – user17732522 Nov 30 '22 at 20:48

0 Answers0