2-Way Communication between classes

Using:  MS Visual Studio 6.0 & Unix

Situation:  I'm creating a simulation of the MVA.  I have 2 classes that need to communicate to each other, and Event and Mva class.

Problem:  Having a clean compile between the two.  In other words my Event class when i compile it says:
         ---- Event.cpp ----
   'Event' : function should return a value; 'void' return type assumed
   syntax error : missing ';' before 'public'
   'operator <' must have at least one formal parameter of class type

          ----- Mva.cpp ------
   syntax error : identifier 'Event'
   'Queue' : 'Event' is invalid as template argument '#1', type expected

so it seems it's not recognizing my Event class as a "class".????

---------------------------------------------------------------------------------------------------------

****** Event.h********
#ifndef EVENT_H
#define EVENT_H

class Mva;
class Event()
{
      public:
                                Event();
                                void execute(Mva &);
                .
                .
                private:
                .
                .
};

***** Event.cpp ******
#include "Mva.h"


***** Mva.h *********
#ifndef MVA_H
#define MVA_H

#include "Event.h"
class Mva
{
      public:
            Mva();
                                bool getNextEvent(Event &);
                                .
                                .
                private:
                                Queue<Event>  eventList;
                                .
};
capnjazzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alex_rCommented:
Are you sure that this is

class Event() { ....

and not:

class Event {

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
That is certainly A problem and probably THE problem.  Alex, you should answer.
0
capnjazzAuthor Commented:
i might as well just smack myself

also...this one's driving me crazy.
error:  too many initializers
char types[] = { "Arrival", "SignIn", "Renewal", "Register", "Cashier" };

thanks, i really just needed someone else to take a look @ it for me.


void Mva::addEvent(const Event &e)
{
      char types[] = { "Arrival", "SignIn", "Renewal", "Register", "Cashier" };
      cout << "Event Added: " << types[e.getState()] << endl;

      eventList.enqueue(e);
}
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

nietodCommented:
"char types[]" defines A array (a one-dimensional array) of characters.  You need to define a 2 dimensional array of characters, like

char types [20][]

or better yet (usually better, it depends) define a 1 dimensonal array of character pointers, like

char *types[] = {'Arrival", ....};
0
capnjazzAuthor Commented:
stress will do it to you.  thanks
0
basantCommented:
Is anything left.
0
nietodCommented:
>> Is anything left
If not, capnjass, you should close the question.  If alex_r helped you, you should accept his comment as an answer.  Otherwise, if no expert helped you enough, you can delete the question.
0
capnjazzAuthor Commented:
there's always more... hopefully this is it.

i'm getting: an array may not have elements of this type.
char types[5][] = { "Arrival", "SignIn", "Renewal", "Register", "Cashier" };
0
nietodCommented:
That is because the array you declared is an array of another array whose type is char[5].  This array is not long enough to store the names you specified.   You could do

char types[20][] = { "Arrival", "SignIn", "Renewal", "Register", "Cashier"};

but that makes ever entry 20 chars long, enough to store a 19 character long string.  That means it wastes space when some words are shorter.

If the array will not be changed during the course of the program, as is often the case with this sort of data, you should instead use

const char *types[] = { "Arrival", "SignIn", Renewal", "Register", "Cashier"};

This is usually more space efficient because it stores pointers to the character arrays and these character arrays are just the length that is needed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.