hi guys

I got this weird error which I cannot debug in my code. The program is to convert Roman numerals to Arabic numerals using the Interpreter design pattern. Here is a part of the program where the errors occurs

RNInterpreter.C:8: error: new types may not be defined in a return type
RNInterpreter.C:8: note: (perhaps a semicolon is missing after the definition of ‘Thousand’)
RNInterpreter.C:8: error: two or more data types in declaration of ‘RNInterpreter’

I know what the error means but I can't seem to find it.The default constructor doesn't have a return type where I made objects of the classes but the error occurs there

any help will be appreciated!Thanks

#include "RNInterpreter.h"
#include "Thousand.h"
#include "One.h"
#include "Hundred.h"
#include "Ten.h"


RNInterpreter::RNInterpreter(){
	thousands = new Thousand(1);
	hundreds = new Hundred(1);
	tens = new Ten(1);
	ones = new One(1);
}

which is the implementation file of this header file(only part of the file is shown above):

#ifndef RNINTERPRETER_H
#define RNINTERPRETER_H

#include <cstring>

class RNInterpreter
{
	public:
		RNInterpreter();
		RNInterpreter(int);
		int interpret(char*);
		virtual void interpret(char* input,int&total);

	private:
		RNInterpreter* thousands;
		RNInterpreter* hundreds;
		RNInterpreter* tens;
		RNInterpreter* ones;

	protected:
		char one();
		char* four();
		char five();
		char* nine();
		int multiplier();

}; 
#endif

Recommended Answers

All 2 Replies

>> RNInterpreter.C:8: note: (perhaps a semicolon is missing after the definition of ‘Thousand’)

Your compiler is suggesting that Thousand.h looks like

class Thousand
{
  // All your Thousand stuff here ...

} // <--- ... but no ending semicolon after the curly bracket

ah man...I hate such small mistakes

Thanks for the quick help!

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.