由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - c++ class design issue
相关主题
Help: How to extract the numberic value in a sentence? 如何编程实现以下简单的组合问题
教授的问题(C language)Need a regular expression for password
[合集] Python下面如何进行numeric analysis and statistical analysis一个小问题
子类的assignment operator 怎么访问父类的private member编译 64/32 位的library (Linux)
dynamic_cast operator in C++[合集] 有人用过gasdev()产生随即数吗?求救!
How to sort a map in C++ STL based on Value, instead of Key问一下Python的情况
STL里面#include的问题[合集] a problem about stl compose1
C++里有没有实现interpolation的函数?急用:谁有C Recipe原文及代码呀?
相关话题的讨论汇总
话题: number话题: returns话题: operation话题: numeric话题: former
进入Programming版参与讨论
1 (共1页)
l*********s
发帖数: 5409
1
You will be creating three classes. The first class is called Number, which
supports three operations:
“display”, “==”, and “+”.
1. display: This operation displays the Number itself in its original form (
I will explain later).
2. ==: This operation returns true if two Numbers are numerically the same.
3. +: This operation adds the number itself with another number and returns
a third number
whose numeric value is equal to the sum of the numeric values of the former
two.
l*********s
发帖数: 5409
2
学艺不精,遇到点问题:
Number类应该是个虚拟类吧,但是加法函数的接口怎么写呢?做为方法的话,返回值是
Number的话Fraction和Integer子类无法实例化,不写又不合规定,加上参数次序的问
题,怎么都很别扭!

which
(
returns
former

【在 l*********s 的大作中提到】
: You will be creating three classes. The first class is called Number, which
: supports three operations:
: “display”, “==”, and “+”.
: 1. display: This operation displays the Number itself in its original form (
: I will explain later).
: 2. ==: This operation returns true if two Numbers are numerically the same.
: 3. +: This operation adds the number itself with another number and returns
: a third number
: whose numeric value is equal to the sum of the numeric values of the former
: two.

b*******s
发帖数: 5216
3
你以前没接触过c++吗?

【在 l*********s 的大作中提到】
: 学艺不精,遇到点问题:
: Number类应该是个虚拟类吧,但是加法函数的接口怎么写呢?做为方法的话,返回值是
: Number的话Fraction和Integer子类无法实例化,不写又不合规定,加上参数次序的问
: 题,怎么都很别扭!
:
: which
: (
: returns
: former

N******K
发帖数: 10202
4
用template不就行了?

which
(
returns
former

【在 l*********s 的大作中提到】
: You will be creating three classes. The first class is called Number, which
: supports three operations:
: “display”, “==”, and “+”.
: 1. display: This operation displays the Number itself in its original form (
: I will explain later).
: 2. ==: This operation returns true if two Numbers are numerically the same.
: 3. +: This operation adds the number itself with another number and returns
: a third number
: whose numeric value is equal to the sum of the numeric values of the former
: two.

b***i
发帖数: 3043
5
你的要求不清楚阿.你先说这里有三个类,然后就说了第一个类叫Nmber。然后这里又提
到Fraction。那么他们的要求到底是什么?

【在 l*********s 的大作中提到】
: 学艺不精,遇到点问题:
: Number类应该是个虚拟类吧,但是加法函数的接口怎么写呢?做为方法的话,返回值是
: Number的话Fraction和Integer子类无法实例化,不写又不合规定,加上参数次序的问
: 题,怎么都很别扭!
:
: which
: (
: returns
: former

X****r
发帖数: 3557
6
Both operator == and operator + likely need to use double dispatch
for a meaningful implementation.

which
(
returns
former

【在 l*********s 的大作中提到】
: You will be creating three classes. The first class is called Number, which
: supports three operations:
: “display”, “==”, and “+”.
: 1. display: This operation displays the Number itself in its original form (
: I will explain later).
: 2. ==: This operation returns true if two Numbers are numerically the same.
: 3. +: This operation adds the number itself with another number and returns
: a third number
: whose numeric value is equal to the sum of the numeric values of the former
: two.

l*********s
发帖数: 5409
7
就是顶贴的要求,已经搞定了,惭愧。

【在 b***i 的大作中提到】
: 你的要求不清楚阿.你先说这里有三个类,然后就说了第一个类叫Nmber。然后这里又提
: 到Fraction。那么他们的要求到底是什么?

l*********s
发帖数: 5409
8
是的,一开始想歪了。

【在 N******K 的大作中提到】
: 用template不就行了?
:
: which
: (
: returns
: former

1 (共1页)
进入Programming版参与讨论
相关主题
急用:谁有C Recipe原文及代码呀?dynamic_cast operator in C++
C 和 C++ 相比有什么优点?How to sort a map in C++ STL based on Value, instead of Key
请问 C#除了作GUI开发,还有什么好处?STL里面#include的问题
A question about Boost/lambdaC++里有没有实现interpolation的函数?
Help: How to extract the numberic value in a sentence? 如何编程实现以下简单的组合问题
教授的问题(C language)Need a regular expression for password
[合集] Python下面如何进行numeric analysis and statistical analysis一个小问题
子类的assignment operator 怎么访问父类的private member编译 64/32 位的library (Linux)
相关话题的讨论汇总
话题: number话题: returns话题: operation话题: numeric话题: former