mercredi 28 mars 2018

Argument of type __ Incompatible with Parameter of type __

I'm a student in a college creating a small little stock market simulator game for a class. We were asked to specifically use structures as opposed to classes, which I'm more well-versed in.

I'm trying to set up an array of "Stock" structure objects, and am attempting to pass (either/or, both have failed) the array of Stock objects and the Stock objects themselves to a function, each in a separate file. This is the Stock structure.

struct Stock {
 string FullName;
 string Ticker;
 string Info;
 string Chairman;
 double Revenue;
 double AvgVol;
 double High52;
 double Low52;
 double CurrentPrice;
 Stock() {
     FullName = "";
     Ticker = "";
     Info = "";
     Chairman = "";
     Revenue = 0;
     AvgVol = 0;
     High52 = 0;
     Low52 = 0;
     CurrentPrice = 0;
 } };

This is in it's own file dedicated specifically for creating various structures used throughout the game. This is how I attempt to create and call the stocks in the main driver function.

Stock Apple;
Stock Chipotle;
Stock Disney;
Stock Tesla;
Stock stockList[4] = { Apple, Chipotle, Disney, Tesla }; //Will access the stocks from this array from here on in
SetupStructs(stockList); //Function that creates the 4 company's information as struct objects to be utilized later

This is the SetupStructs function in a third file, dedicated specifically for functions, so as to not clog up the main file.

void SetupStructs(Stock stockList[]) {

stockList[0].FullName = "Apple Incorporated";

stockList[1].FullName = "Chipotle Mexican Grill Incorporated";

stockList[2].FullName = "Walt Disney Company";

stockList[3].FullName = "Tesla Motors Incorporated"; };

If it's not obvious, I've left 90% of the rest of the SetupStructs function out of what I pasted so as to not clog up the page with unnecessary code.

The problem is: "SetupStructs(stockList)" is throwing the error:

argument of type "Stock *" is incompatible with parameter of type "Stock *"

What am I doing wrong? Where is this error appearing? Apologies for the mini-essay.

Aucun commentaire:

Enregistrer un commentaire