So i have this class called Numbers and I want to be able to take in doubles or integers.
I know i have to use templates but I'm confused can anyone guide me in the right direction.
suppose i have private member functions set to int how can I change those to doubles
how can I use a template to change those to doubles?
csnerd2020
0
Newbie Poster
Recommended Answers
Jump to PostIf you already have the class, you could do worse than simply change your existing code into template and see what happens.
If you class, for example, looks like this:
class Numbers { private: int theValue; public: int getValue(){ return theValue;} void setValue(int input){theValue = input;} }; …
All 4 Replies
Moschops
683
Practically a Master Poster
Featured Poster
csnerd2020
0
Newbie Poster
Moschops
683
Practically a Master Poster
Featured Poster
Maritimo
15
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.