Xcode Errors for C++

Hey there, so I'm a beginning program student and we have this assignment to build a program for a fish store. It's on the inventory. We cannot use classes. Anyway, I've been getting lots of the same errors in X-code and I cannot for the life of me figure out what they mean or how to fix them. Can someone please help me? The errors I'm getting are: Parse Issue: Expected "(" for function-style cast or type construction, and Semantic Issue: Redefinition of 'addFish', 'removeFish', 'searchFish','writeFishFile' and 'fishFile' as different kind of symbol. Here's my "functions.h" and my main function:
[code]
// functions.h
// Programming assignment#2
//
// Created by Isabella Perry on 10/17/14.
// Copyright (c) 2014 Isabella Perry. All rights reserved.
//

#ifndef Programming_assignment_2_functions_h
#define Programming_assignment_2_functions_h
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include "pa2.cpp"
using namespace std;



void displayMenu()
{
cout << "1. View Fish Inventory " << endl;
cout << "2. Read Fish Inventory from a File " << endl;
cout << "3. Write Fish Inventory to a File "<< endl;
cout << "4. Add Fish to inventory " << endl;
cout << "5. Remove Fish from Inventory " << endl;
cout << "6. Search for Fish " << endl;
cout << "7. Update Quantity " << endl;
cout << "8. Update Tank/Location " << endl;
cout << "9. Exit " << endl;
}

void displayInventory (myInventory,MAX_SIZE, int currentsize)
{
cout << "Here is your inventory:" << endl;
cout << fixed << setprecision(2);
cout << "Name" << setw(20) << "Tank/Location" << setw(8) << "Quantity" << setw(10)<< "Price" << endl;
cout << "--------------------------------------------------------------------------------------" << endl;
cout << left;
for (int a = 0; a < currentsize; a++)
{
cout << myInventory[a].name << right;
cout << setw(20) << myInventory[a].tank
cout << setw(8) << myInventory[a].quantity << right;
cout << setw(10) << myInventory[a].price << right << endl;
cout << "--------------------------------------------------------------------------------------" << endl;


}



}
int fishFile(myInventory, MAX_SIZE, int currentsize)
{
currentsize = 0;
ifstream fishyfile("fish.txt");
string str;
stringstream strstrm;

while (fishyfile() && currentsize < MAX_SIZE)
{
getline(fishyfile, str, ';');
myInventory[currentsize].name = str;

getline(fishyfile, str, ';')
strstrm(" "); strstrm.clear();
strstrm << str;
strstrm >> myInventory[currentsize++].tank;
strstrm >> myInventory[currentsize++].quantity;
strstrm >> myInventory[currentsize++].price;

fishyfile.close();


}





}

int writeFishFile(myInventory, MAX_SIZE, int currentsize)
{
ofstream fishyfile("fish");
for (int a = 0; a < currentsize; a++)
{
fishyfile << myInventory[a].name << ';'
<< myInventory[a].tank << ';'
<< myInventory[a].quantity <<';'
<< myInventory[a].price;
if ( a < currentsize-1) fishyfile << endl;
}

fishyfile.close();

}


int addFish(myInventory, MAX_SIZE, int currentsize)
{
cout << "Please enter the name of the fish" << endl;
cin >> myInventory[currentsize].name;
cout << "Please enter the tank/location" << endl;
cin >> myInventory[currentsize].tank;
cout << "Please enter the quantity" << endl;
cin >> myInventory[currentsize].quantity;
cout << "Please enter the price" << endl;
cin >> myInventory[currentsize].price;

cout << "Name: " << myInventory[currentsize].name << endl;
cout << "Tank: " << myInventory[currentsize].tank << endl;
cout << "Quantity" << myInventory[currentsize].quantity << endl;
cout << "Price:" << myInventory[currentsize].price << endl;
cout << "has been added to your inventory!" << endl;
}

int removeFish( myInventory, MAX_SIZE, int currentsize)
{

string deleteFish;
cout << "Please enter the name of the fish you would like to remove from inventory:" << endl;
cin >> deleteFish;
if ( currentsize < deleteFish-1)
{
myInventory[currentsize] = myInventory[deleteFish-1];
}

--deleteFish;

cout << "Your item has been deleted" << endl;

}
}

bool searchFish( myInventory, MAX_SIZE, int currentsize)
{
string fish;
cout << "Please enter the name of the fish you would like to search for: " << endl;
cin >> fish;
for (int i = 0; i < currentsize;++i)
{
if (fish == myInventory[i])
return true;
else
cout << "I'm sorry, the item you entered cannot be found in your inventory" << endl;
}




}

int updatenum( myInventory, MAX_SIZE, int currentsize)
{
int choice;
int newtotal;
int upbyone;
int downbyone;
void newtotal(int);
string fish;
cout << "Please enter the name of the fish you would like to search for: " << endl;
cin >> fish;
for (int i = 0; i < currentsize;++i)
{
if (fish == myInventory[i])
{ return true;
cout << myInventory[i].name;
cout << myInventory[i].tank;
cout << myInventory[i].quantity;
cout << myInventory[i].price << endl;

cout << "What would you like me to do?"
cout << " 1. New total quantity" << endl;
cout << " 2. Decrease by one" << endl;
cout << " 3. Increase by one" << endl;
cin >> choice;

switch (choice)
{
case 1: newtotal(newvalue);
case 2: downbyone = fish--;
case 3: upbyone = fish++;

}

void newtotal( int newvalue)
{
int num;
cout << "Please enter the new total quantity" << endl;
cin >> num;
newvalue = myInventory[i].quantity + num;
}
}

else
cout << "I'm sorry, the item you entered cannot be found in your inventory" << endl;
}


}

int updateTank( myInventory, MAX_SIZE, int currentsize)
{
int num;
displayInventory(myInventory,MAX_SIZE, currentsize);
cout << "Which fish information would you like to change?" << endl;
cin >> myInventory.name;
cout << "What tank would you like to change to?" << endl;
cin >> num;
myInventory.tank = num;
cout << "New tank: " << num << endl;


}

void exitOut()
{
return 0;
}

#endif


//This program is a catalog for a fish store.
//Isabella Perry (PERRYI)

#include <iomanip>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include "functions.h"
using namespace std;

struct Fish
{
string name;
int tank;
int quantity;
double price;
};


const int MAX_SIZE = 100;
Fish myInventory[MAX_SIZE];


void displayMenu(); //displays menu
void displayInventory();// displays inventory
int fishFile(myInventory, MAX_SIZE,int); // Reads fish inventory from a file
int writeFishFile(myInventory, MAX_SIZE, int); // Writes fish inventory to a file
int addFish(myInventory, MAX_SIZE, int); // Adds fish inventory to a file
int removeFish(myInventory,MAX_SIZE,int);// Removes Fish from Inventory
bool searchFish(myInventory,MAX_SIZE,int); // Searches fish inventory
int updatenum(myInventory, MAX_SIZE, int); // Updates fish Inventory
int updateTank(myInventory, MAX_SIZE, int); // Updates tank
void exitOut(); // Exit outs of program

int main (void)

{

int choice;
int currentSize;
Fish fishy;



cout << "Please select an option: " << endl;
displayMenu();
cin >> choice;

switch (choice)
{
case 1: displayInventory();
break;
case 2: fishFile(myInventory, MAX_SIZE, *currentSize);
break;
case 3: writeFishyFile(myInventory, MAX_SIZE, *currentSize);
break;
case 4: addFish(myInventory, MAX_SIZE,currentSize);
break;
case 5: removeFish(myInventory, MAX_SIZE, currentSize);
break;
case 6: searchFish(myInventory,MAX_SIZE, currentSize);
break;
case 7: updatenum(myInventory, MAX_SIZE,currentSize);
break;
case 8: updateTank(myInventory,MAX_SIZE, currentSize);
break;
case 9: exitOut();
break;

}



return 0;
}
Your problem is that you are not clear of how to create a function. You can't create a function like what you did. You have to create functions like this in C/C++:

1
2
3
ReturnType FunctionName(ParameterType1 parameter1, ParameterType2 parameter2)
{
}



Topic archived. No new replies allowed.