Hello Everyone,
I am working on this Eclipse development tutorial from IBM.
I had already installed Eclipse prior to finding this tutorial and had installed MinGW instead of Cygwin. But other than that change, I followed the "Lottery" programming tutorial precisely until I got stuck at the Running the Program section.
Here I get several errors (most of which occur in the main.cpp)
-----------------------------------------------------------------------------------------
***main.cpp***
"class lotto::LotteryFactory has no member named 'getLottery'
"endl was not declared in this scope"
"scanf was not declared in this scope"
"expected primary-expression before '->'"
"expected primary-expression before ';'
"expected primary-expression before '='
***LotteryFactory.h****
"ISO C++ forbids declaration of 'Lottery' with no type"
"expected ';' before '*'"
-----------------------------------------------------------------------------------------
Here's my code:
___________________________________________________________________________
main.cpp
#include <iostream>
#include "LotteryFactory.h"
using namespace lotto;
int main()
{
LotteryFactory* factory = LotteryFactory::getInstance();
cout << "What lottery do you want to play?" << endl;
cout << "(1) California, (2) Florida" << endl;
int cmd;
scanf("&d", &cmd);
Lottery* lotto=0;
switch (cmd)
{
case 1:
lotto = factory->getLottery(LotteryFactory::California);
break;
case 2:
lotto = factory->getLottery(LotteryFactory::Florida);
break;
default:
cout<<"Sorry didn't understand that" << endl;
}
cout << "Ticket: " << lotto->printTicket() << endl;
delete lotto;
return 0;
}
______________________________________________________________________________
LotteryFactory.h:
#ifndef LOTTERYFACTORY_H_
#define LOTTERYFACTORY_H_
namespace lotto {
class LotteryFactory
{
public:
enum State { California, Florida };
static LotteryFactory* getInstance();
Lottery* getLottery(State);
private:
LotteryFactory();
};
}
#endif /* LOTTERYFACTORY_H_ */
__________________________________________________________________
Let me know if I should provide any further information about my errors.
Thank you!
L