Ok firstly I want to show you my code here:

Trader.h file

const int NumSeller = 1;
const int NumBuyer = 1;
const int NumBids = 10;
const int MinQuantity = 1;
const int MaxQuantity = 30;
const int MinPrice =50;
const int MaxPrice = 100;

class Trader {
      private:
             int bidID;
             int traderID;
             char type;
             int quantity;
             int price;
      public:
             void buy();
             void sell();
             string storeBids();
};

void Trader :: buy() {
     struct Trader bids[NumBids + 1];
             for(int x = 0; x < NumBids; x++)
             {
                     traderID=0;
                     type = 'B';
                     bids[x].quantity = ((rand() % MaxQuantity) + MinQuantity); 
                     bids[x].price = ((rand() % MaxPrice - MinPrice) + MinPrice); 
             };

             for(int i = 0; i < NumBids; i++)
             {
                     cout << "(" << bidID++ << ", " << traderID << ", " << type << ", " <<
                     bids[i].quantity << ", " << bids[i].price << ")" << endl;
                     };
};

void Trader :: sell() {
     struct Trader bids[NumBids + 1];
            for(int x = 0; x < NumBids; x++)
            {
                    traderID=1; 
                    type = 'A';
                    bids[x].quantity = ((rand() % MaxQuantity) + MinQuantity); 
                    bids[x].price = ((rand() % MaxPrice - MinPrice) + MinPrice); 
            };
            
            for(int i = 0; i < NumBids ; i++)
            {
                    cout << "(" << bidID++ << ", " << traderID << ", " << type << ", " <<
                    bids[i].quantity << ", " << bids[i].price << ")" << endl;
            };
};

string Trader :: storeBids() {
       stringstream stream;
       stream << "(" << bidID << ", " << traderID << ", " << type << ", " <<
       bids[i].quantity << ", " << bids[i].price << ")" << endl;
       return stream.str();
}

and Auctioneer.h file

class Auctioneer {
      private:
              Trader trader;
              stringstream stream;
      public:
             void receiveBids;
             void displayBids(stringstream);
             void run();
};

Auctioneer auctioneer;

void Auctioneer :: run() {
     trader.storeBids();
     auctioneer.receiveBids(trade.storeBids());
}

void displayBids(stringstream stream) {
     stream.str();
}

and the MAIN.cpp file

int main() {
    Auctioneer auctioneer;
    auctioneer.run();
    system("pause");
    return 0;
}

The Trader.h file one can run properly (without Auctioneer.h) and they output like that:
(0, 0, B, 12, 67)
(1, 0, B, 5, 0)
(2, 0, B, 30, 24)
(3, 0, B, 19, 58)
(4, 0, B, 23, 64)
(5, 0, B, 6, 45)
(6, 0, B, 2, 27)
(7, 0, B, 2, 91)
(8, 0, B, 26, 42)
(9, 0, B, 28, 36)
(10, 1, A, 22, 4)
(11, 1, A, 3, 53)
(12, 1, A, 23, 82)
(13, 1, A, 22, 16)
(14, 1, A, 9, 95)
(15, 1, A, 18, 26)
(16, 1, A, 12, 38)
(17, 1, A, 10, 12)
(18, 1, A, 18, 99)
(19, 1, A, 26, 94)

But I created the Auctioneer file as I wanted that program file to collect the information from Trader (like the output one) but it has alot of error. I want both Trader.h and Auctioneer.h to be able to communicate with each other. Like the Auctioneer need to store the bids from Trader, without a text file at all, and so Auctioneer will match the bids (don't worry about that yet).

That's not much to go on. Care to elaborate a little?

string Trader :: storeBids() {
       stringstream stream;
       stream << "(" << bidID << ", " << traderID << ", " << type << ", " <<
       bids[i].quantity << ", " << bids[i].price << ")" << endl;
       return stream.str();
}

:confused:
that code in the Trader file - I tried to create that function as it should store the output, then it sends the information to Auctioneer so Auctioneer.h will match the bids and display them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.