Ok, this is my first post, be easy. I'm quite new to c++ programming. I am trying to make a simple feet to inches converter. It works perfectly except for when I try to to loop it. I've tried using a while loop (for when feet >=0) around the function calls but it tells me feet is not defined in the scope. How can I go about looping this program until user types in a negative number.
Additional Information: I haven't set feet equal to any number once it first gets to the while loop, so I'm thinking that's the problem. However, I can't set it equal to anything in the class or before the loop without getting more errors.
Here is the code:
using namespace std;
template <class Q>
cout << "Welcome to the feet to inches converter.\nEnter how many feet you would like to be converted:\n";
cout << "(Enter negative number to quit)\n";
cin >> feet;
// inside while should be accessor func obj.getFeet( )
(1) I believe the feet you're trying to to use is in the object: conversion <double> obj, so you need to use obj.feet instead of just feet.
(2) Unfortunately you cannot use obj.feet since you declared it as private in your class. To solve this I would recommend creating an accessor function. You can always change feet to be public, but that would go against the purpose of classes.