J
jerry.upstatenyguy
I am really stuck on this. I am trying to write a string array
containing a "word" and a "definition" to a class called Entry.
Ultimately this will end up in another class called dictionary. No,
this is not a homework assignment. In fact it was a question on my
class midterm that everyone bombed. Unfortunately we never covered
this in class prior to the midterm.
Anyway, please help if you would be so kind.
Here is what I have. I think I am messing up on the proper syntax.
This errors when I try to compile.
Class File:
//CLASS FILE - Entry.h
#include <iostream>
using namespace std;
#include <string>
using namespace std;
class Entry
{
public:
Entry(string[], string[]);
void setEntry (string[], string[]);
private:
string word[10];
string definition[10];
};
//MEMBER FUNCTION FILE - Entry.cpp
#include <iostream>
using namespace std;
#include <iomanip>
using namespace std;
#include <string>
using namespace std;
#include "Entry.h"
Entry::Entry();
void Entry::setEntry(string w[], string d[])
{
int i = 0;
word = w;
definition{i} = d;
i = ++i;
}
//MAIN FILE - Midterm.cpp
#include "Entry.h" // Entry class definition
// function main begins program execution
int main()
{
Entry w1;
w1.setEntry("Car", "Something you drive");
return 0;
} // end main
Here is the ERROR:
1>------ Build started: Project: Midterm, Configuration: Debug Win32
------
1>Compiling...
1>Entry.cpp
1>Midterm.cpp
1>Build log was saved at "file://c:\Documents and Settings\John\My
Documents\Visual Studio
2005\Projects\Midterm\Midterm\Debug\BuildLog.htm"
1>Midterm - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
containing a "word" and a "definition" to a class called Entry.
Ultimately this will end up in another class called dictionary. No,
this is not a homework assignment. In fact it was a question on my
class midterm that everyone bombed. Unfortunately we never covered
this in class prior to the midterm.
Anyway, please help if you would be so kind.
Here is what I have. I think I am messing up on the proper syntax.
This errors when I try to compile.
Class File:
//CLASS FILE - Entry.h
#include <iostream>
using namespace std;
#include <string>
using namespace std;
class Entry
{
public:
Entry(string[], string[]);
void setEntry (string[], string[]);
private:
string word[10];
string definition[10];
};
//MEMBER FUNCTION FILE - Entry.cpp
#include <iostream>
using namespace std;
#include <iomanip>
using namespace std;
#include <string>
using namespace std;
#include "Entry.h"
Entry::Entry();
void Entry::setEntry(string w[], string d[])
{
int i = 0;
word = w;
definition{i} = d;
i = ++i;
}
//MAIN FILE - Midterm.cpp
#include "Entry.h" // Entry class definition
// function main begins program execution
int main()
{
Entry w1;
w1.setEntry("Car", "Something you drive");
return 0;
} // end main
Here is the ERROR:
1>------ Build started: Project: Midterm, Configuration: Debug Win32
------
1>Compiling...
1>Entry.cpp
1>Midterm.cpp
1>Generating Code...c:\documents and settings\john\my documents\visual studio 2005\projects\midterm\midterm\midterm.cpp(24) : error C2660: 'Entry::setEntry' : function does not take 2 arguments
1>Build log was saved at "file://c:\Documents and Settings\John\My
Documents\Visual Studio
2005\Projects\Midterm\Midterm\Debug\BuildLog.htm"
1>Midterm - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========