I have a class which accepts vectors from another class called trader. This is the simulator class:

#include<vector>
using namespace std;

class Simulator 
{
	Trader trader;
	Auctioneer auction;
public:
	void run();
};

void Simulator::run() 
{
	trader.setBid(); 

    auction.BidID(trader.getBidID(vector<int>));
    auction.TraderID(trader.getTraderID(vector<int>));
    auction.Quantity(trader.getQuantity(vector<int>));
    auction.Price(trader.getPrice(vector<int>));
    auction.Type(trader.getType(vector<char>));
    auction.showbid();
    auction.matchBids();
};

In these lines:

auction.BidID(trader.getBidID(vector<int>));
    auction.TraderID(trader.getTraderID(vector<int>));
    auction.Quantity(trader.getQuantity(vector<int>));
    auction.Price(trader.getPrice(vector<int>));
    auction.Type(trader.getType(vector<char>));

It gives me an error saying:
Simulator.h expected primary-expression before ')' token

Anyone know what the problem may be?I've included the header files bt it still wont work:S

Recommended Answers

All 5 Replies

This is the trader class incase u need it:

#include<vector>
using namespace std;

int NUMSELLER =1;
int NUMBUYER =1;
int NUMBIDS=10;
int MINQUANTITY=1;
int MAXQUANTITY=30;
int MINPRICE=50;
int MAXPRICE =150;

class Trader 
{
private:
        int bidID [100] ;
        int traderID [100];
        char tradertype [100];
        int quantity[100];
        int price[100];
public:
//***************Function to Set Bids********************      
vector<int> getBidID(vector<int>);
vector<int> getTraderID(vector<int>);
vector<int> getQuantity(vector<int>);
vector<int> getPrice(vector<int>);
vector<char> getType(vector<char>);
void setBid();

};
//********************************** 
vector<int> Trader::getBidID(vector<int> bidID)
 {
    vector<int> bid;
    for(int i=0;i<(NUMBIDS*2);i++)
    bid.push_back(bidID[i]);
     
    return bid;
 }
//**********************************                               
vector<int> Trader::getTraderID(vector<int>traderID)
 {
    vector<int> tid;
    for(int i=0;i<(NUMBIDS*2);i++)
    tid.push_back(traderID[i]);
    return tid;
 }
//********************************** 

vector<int> Trader::getQuantity(vector<int> quantity)
 {
   vector<int> qty;
   for(int i=0;i<(NUMBIDS*2);i++)
   qty.push_back(quantity[i]);
   return qty;
 }
//********************************** 
vector<int> Trader::getPrice(vector<int> price)
 {
   vector<int> pr;
   for(int i=0;i<(NUMBIDS*2);i++)
   pr.push_back(price[i]);
   return pr;
 }
//********************************** 
                              
vector<char> Trader::getType(vector<char> tradertype)
 {
   vector<char> type;
   for(int i=0;i<(NUMBIDS*2);i++)
   type.push_back(tradertype[i]);
   return type;
 } 
//********************************** 
void Trader::setBid() 
{
 
   int range1 = ( MAXPRICE - MINPRICE ) + 1;
   int range2 = ( MAXQUANTITY- MINQUANTITY ) + 1;

 for(int i=0;i<=NUMSELLER;i++)
  {       
  for(int j=0;j<NUMBIDS;j++)  
    {
    
          if(i==0)
          {
              tradertype[j]='A'; 
              bidID[j]=j; 
              traderID[j]=i; 
              quantity[j] =MINQUANTITY + int ( range2 * rand() / ( RAND_MAX + 1.0 ) );
              price[j] = MINPRICE + int ( range1 * rand() / ( RAND_MAX + 1.0 ) ) ;
              }             
          if(i==1)
          {
              tradertype[j+NUMBIDS]='B';
              bidID[j+NUMBIDS]=j+NUMBIDS;
              traderID[j+NUMBIDS]=i;
              quantity[j+NUMBIDS] = MINQUANTITY + int ( range2 * rand() / ( RAND_MAX + 1.0 ) );
              price[j+NUMBIDS] =  MINPRICE + int ( range1 * rand() / ( RAND_MAX + 1.0 ) ) ;

              }
       }
     }
}

vector<int> is a type, but those member functions are expecting an actual object of the type.

So...What should i put in it?Should i leave it blank?:|
Sorry im kinda learning vectors nowdays so im not really good at understanding them:S

Should i leave it blank?

No, those are required parameters. Have you tried creating a vector object and passing that? I mean, it only makes sense since your Trader class makes use of the data stored within the arguments.

Sorry im kinda learning vectors nowdays so im not really good at understanding them

There's nothing terribly new in this case. Would you do this?

int add(int a, int b)
{
    return a + b;
}

int main()
{
    cout<< add(int, int) <<'\n';?
}

Obviously not. It's nonsensical to do so. You're doing the same thing, except instead of int, you're using vector<int> and vector<char>. The solution is the same as well:

int add(int a, int b)
{
    return a + b;
}

int main()
{
    // Create objects of the appropriate type
    int a;
    int b;

    // Initialize the objects to suitable values
    a = 2;
    b = 4;

    // Pass the objects rather than the type
    cout<< add(a, b) <<'\n';?
}

Oh!!Ok..I kinda got that!Let me just try fixing it!Thanks!:)

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.