Mystofolyse
Weaksauce
- Joined
- Jun 25, 2006
- Messages
- 103
Just running through the beginnings of data structures, and I'm getting some unfortunate errors. The program is going to convert a Roman numeral into decimal form. The implementations several of the methods aren't complete, as I compiled early and with the listed code. I can't seem to figure out where to go with this. Using VS2008 by the way. Thank you for the help!
Specification file:
Implementation file:
Compiler output:
I'm probably overlooking something glaringly obvious, but I can't see it.
Specification file:
Code:
class romanType
{
public:
// Default constructor
// Postcondition: roman = "" and
// decimal = 0
romanType();
// Constructor with one parameter
// Postcondition: roman = rNumeral
romanType(string rNumeral);
// Sets roman to the value of rNumeral
// Precondition: rNumeral is a valid string
// Postcondition: roman = rNumeral
void setRoman(string rNumeral);
// Prints the decimal value
// Precondition: decimal is a valid integer
// Postcondition: decimal is printed to cout
void printDecimal();
private:
// Converts a Roman numeral to decimal form
// Postcondition: decimal will be 'equal' to
// roman
void convert();
string roman;
int decimal;
}
Implementation file:
Code:
#include "romanType.h"
#include <iostream>
#include <string>
// Default constructor
// Postcondition: numeral = "" and
// decimal = 0
romanType::romanType()
{
roman = "";
decimal = 0;
}
// Constructor with one parameter
// Postcondition: numeral = num
romanType::romanType(string rNum)
{
roman = rNum;
}
// Sets numeral to the value of num
// Precondition: num is a valid string
// Postcondition: numeral = num
void romanType::setNumeral(string rNum)
{
}
// Prints the decimal value
// Precondition: decimal is a valid integer
// Postcondition: decimal is printed to cout
void romanType::printDecimal()
{
}
// Converts Roman numeral to decimal form
// Precondition: numeral is a valid Roman numeral
// Postcondition: decimal will be equal to
// numeral
void romanType::convert()
{
}
string roman;
int decimal;
}
Compiler output:
Code:
1>------ Build started: Project: DataStructures01, Configuration: Debug Win32 ------
1>Compiling...
1>romanType.cpp
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(12) : error C2061: syntax error : identifier 'string'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(12) : error C2535: 'romanType::romanType(void)' : member function already defined or declared
1> c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(8) : see declaration of 'romanType::romanType'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(17) : error C2061: syntax error : identifier 'string'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(30) : error C2146: syntax error : missing ';' before identifier 'roman'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(30) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(30) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(19) : error C2628: 'romanType' followed by 'unsigned' is illegal (did you forget a ';'?)
1>c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(19) : error C2628: 'romanType' followed by 'int' is illegal (did you forget a ';'?)
1>c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(19) : error C2347: '__w64' : can not be used with type '__w64 romanType'
1>c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(19) : error C2371: 'size_t' : redefinition; different basic types
1> c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\predefined c++ types (compiler internal)(19) : see declaration of 'size_t'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(10) : error C2065: 'roman' : undeclared identifier
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(16) : error C2065: 'string' : undeclared identifier
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(16) : error C2146: syntax error : missing ')' before identifier 'rNum'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(16) : error C2761: '{ctor}' : member function redeclaration not allowed
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(16) : error C2059: syntax error : ')'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(17) : error C2143: syntax error : missing ';' before '{'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(17) : error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(24) : error C2039: 'setNumeral' : is not a member of 'romanType'
1> c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.h(2) : see declaration of 'romanType'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(24) : error C2065: 'string' : undeclared identifier
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(24) : error C2146: syntax error : missing ')' before identifier 'rNum'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(24) : error C2182: 'setNumeral' : illegal use of type 'void'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(24) : error C2059: syntax error : ')'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(25) : error C2143: syntax error : missing ';' before '{'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(25) : error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(46) : error C2146: syntax error : missing ';' before identifier 'roman'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(48) : error C2059: syntax error : '}'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(48) : error C2143: syntax error : missing ';' before '}'
1>c:\users\jeremy\documents\visual studio 2008\projects\datastructures01\datastructures01\romantype.cpp(48) : error C2059: syntax error : '}'
1>Build log was saved at "file://c:\Users\Jeremy\Documents\Visual Studio 2008\Projects\DataStructures01\DataStructures01\Debug\BuildLog.htm"
1>DataStructures01 - 30 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm probably overlooking something glaringly obvious, but I can't see it.