Hi guys
I am working on a Lottery program to generate 6 unique numbers. So far I have the following:
CLASS LOOKS LIKE THIS:
#include "stdafx.h"
#include <string>
#include <ctime>
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
class Lottery // Lottery class definition
{
public:
Lottery(); // constructor that initializes a Lottery object
void setLottery(int []); // function that gets lottery numbers
int getLottery(); // function that retrieve the lottery numbers
bool checkLottery(int, int []); // function that evaluates the lottery numbers
void displayLottery(int []); // function that displays the lottery numbers
private:
int lotNumbers[6]; // lottery number
}; // end of class Lottery
#include "stdafx.h"
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
#include <ctime>
using std::string;
#include "lottery.h" // include definition of class lottery
// constructor for the Lottery
Lottery::Lottery()
{
} // end of Lottery constructor
bool Lottery::checkLottery(int lotnum, int lottery_numbers[6])
{
for (int i=0; i < 6; i++)
{
if (lottery_numbers[i] == lotnum || lottery_numbers[i] == 0)
{
return false;
}
}
return true;
}
void Lottery::setLottery(int lottery_numbers[6])
{
lotNumbers[6] = lottery_numbers[6];
}
int Lottery::getLottery()
{
return lotNumbers[6];
int lot_count = 0; // counter for the number of valid lottery numbers found
while (lot_count < 6)
{
time_t = t;
srand(unsigned (time(&t)));
int lotnum = (rand() * 53);
if (checkLottery(lotnum, lotnumbers))
{
lotnumbers[lot_count] = lotnum;
lot_count++;
}
}
}
void Lottery::displayLottery()
{
getLottery();
for (int j = 0; j < 6; j++)
{
cout << getLottery() << " ";
}
getche();
}
#include "stdafx.h"
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
#include <ctime>
#include "lottery.h" // iinclude definition of class lottery
// function main begins program execution
int main()
{
int lottery_numbers[6];
Lottery lotteryDraw; //create Lottery object
lotteryDraw.displayLottery();
return 0; // indicate successful termination
} // end main function
I am getting the following errors and I do not understand where to go from here.
wrig_9.cpp
c:\users\jeannie\documents\visual studio 2005\projects\wrig_9\wrig_9\wrig_9.cpp(25) : error C2660: 'Lottery::displayLottery' : function does not take 0 arguments
lottery.cpp
c:\users\jeannie\documents\visual studio 2005\projects\wrig_9\wrig_9\lottery.cpp(47) : error C2513: '__time64_t' : no variable declared before '='
c:\users\jeannie\documents\visual studio 2005\projects\wrig_9\wrig_9\lottery.cpp(47) : error C2065: 't' : undeclared identifier
c:\users\jeannie\documents\visual studio 2005\projects\wrig_9\wrig_9\lottery.cpp(48) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
Build log was saved at "file://c:\Users\Jeannie\Documents\Visual Studio 2005\Projects\wrig_9\wrig_9\Debug\BuildLog.htm"
wrig_9 - 4 error(s), 0 warning(s)
====================================
I think the arrays are not declared properly and the calls are inaccurate.
Any help is appreciated. Please let me know what I am doing wrong.
Thanks so much
techgenie
===============