本文整理汇总了C++中Number::printValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Number::printValue方法的具体用法?C++ Number::printValue怎么用?C++ Number::printValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::printValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
int x1, x2;
double y1, y2;
cout << "Please enter two integers: " << endl;
cin >> x1;
cin >> x2;
// Instantiate "int" objects
Number <int> m (x1);
Number <int> n (x2);
cout << "Calling printValue() on objects 'm' and 'n': " << endl;
m.printValue();
n.printValue();
cout << "Applying '+=' operator to 'm' with input 'n': " << endl;
m += n;
m.printValue();
cout << "Applying '+' operator to define new variable 'sum': " << endl;
Number<int> sum = m + n;
sum.printValue();
// Repeating for doubles
cout << "Now please enter two doubles and repeat: " << endl;
cin >> y1;
cin >> y2;
Number <double> x (y1);
Number <double> y (y2);
cout << "Calling printValue() on double objects 'x' and 'y': " << endl;
x.printValue();
y.printValue();
cout << "Applying '+=' operator: " << endl;
x += y;
x.printValue();
cout << "Applying '+' operator to define new variable 'z': " << endl;
Number<double> z = x + y;
z.printValue();
}