if you have a class that has pointers, is it okay that it can take in pointers and replace it's member ones from the argument of constructor?
class PowerComputation
{
public:
PowerComputation(std::shared_ptr<Numerator>num, std::shared_ptr<Denom>denom);// take in pointers
friend std::ostream& operator<<(std::ostream& output, const PowerComputation&);
private:
std::shared_ptr<Numerator>num=nullptr;
std::shared_ptr<Denom>denom=nullptr;
};
is this okay or does it look like bad practice?
PowerComputation::PowerComputation(std::shared_ptr<Numerator>num, std::shared_ptr<Denom>denom)
{
this->num = num;
this->denom = denom;
}
shared pointer is used since two pointers are pointing to the same memory location
Full code :
https://onlinegdb.com/F-7_Rs4up