TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JAMES NORMAN
from: ALBERTO MONTEIRO
date: 1997-08-31 16:15:00
subject: Roman Numeral??? (hpp)

JN>Hi there :) was wondering if anybody have any ideas or C++ libraries, that
JN>deal with roman numerals??
JN>eg.     put_roman(int num);           which will display the roman numeral
JN>                           depending on which integer (1-3999)
JN>        get_roman();                  which will read a roman numeral
JN>                      string, and return its integer value!!
JN>get_roman() MUST return 1 if invalid string code!! eg. IIV or IC, etc, etc
JN>any help would be greatly appreciated!!! thanx
I've tried to write it, in two blocks: roman.hpp and roman.cpp. I've
tested them, they look fine, but I'm not sure if I've done it right...
// begin of file roman.hpp
//
// Class Roman
// Purpose: work with Roman Numerals
// Programmed by Alberto Monteiro
// Copyright stuff: done by me, used by anyone, credits required, etc
//
//
#include 
//
// The class Roman will store an integer value
// (Roman numerals can only represent positive integers...)
// and its string equivalent. So:
//
class Roman {
public:
  char *str;
  int n;
//
// It's necessary to have two constructors: one that
// takes an integer and converts to roman, and an
// other that gets a string a decodes to roman:
//
  Roman(void);
  Roman(int n0);
  Roman(char *str0);
  ~Roman(void);
//  The only operators I think I must create are the operator
//  to read and to write:
//
  friend ostream& operator<<(ostream&, Roman&);
  friend istream& operator>>(istream&, Roman&);
};
// end of file roman.hpp
//
Roman.cpp follows in next message
---
 þ SLMR 2.1a þ AEquam memento rebus in arduis servare mentem
--- FMail/386 1.02
---------------
* Origin: CentroIn! +55-21-205-0281, 41 lines, 24h, RJ/Brazil (4:802/21)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.