i have a Struct called transaction containing
#pragma once
#include <string>
using std::string;
///////////////////////////////////////////////////////////////////////////////
// Stock Buy Transaction //
///////////////////////////////////////////////////////////////////////////////
/**
* Stock sell transaction
*/
struct Transaction
{
string stockSymbol; // String containing the stock symbol, e.g. "AAPL"
string buyerName; // String containing the buyer's name e.g. "Mr Brown"
int buyerAccount; // Integer containing an eight digit account code
int numShares; // Integer containing the number of sold shares
int pricePerShare; // Integer containing the buy price per share
};
im looking to initialize this struct using
Analyser::Analyser(Transaction* transactions, int numTransactions)
problem is i dont have a clue how?
i have this
/**
* Build a random transaction
*/
static Transaction* buildTransactions(int numTransactions)
{
int maxShareVolume = 100000;
int maxSharePrice = 1000;
Transaction *transactions = new Transaction[numTransactions];
for(int idx = 0; idx < numTransactions; idx++)
{
transactions[idx].stockSymbol = pickRandomStockSymbol();
std::string buyerName = pickRandomBuyer();
transactions[idx].buyerName = buyerName;
transactions[idx].buyerAccount = lookupBuyerAccount(buyerName);
transactions[idx].numShares = 1 + rand() % maxShareVolume;
transactions[idx].pricePerShare = 1 + rand() % maxSharePrice;
}
return transactions;
}
within a file they called setup. im not quite sure how relivant this is?very new to c++ so if anyone could help it would be great.

New Topic/Question
Reply




MultiQuote





|