When I try to execute my main function, I get the error "./main.cpp: line 6: syntax error near unexpected token `(' " I'm not sure what is wrong. Any help would be appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <fstream>
#include <iostream>
#include "Store.h"
#include "Product.h"
int main()
{
Store myStore("storedata");
myStore.print();
myStore.processOrders("orders.txt");
myStore.print();
return 0;
}
I tried removing the Product.h header and the Store.h header just to see if that would get rid of the error, but I still got the same error (except for line 4 instead of line 6).
You can not remove headers because the program uses names declared in these headers. You should look through "Product.h" Maybe you forgot to place a semicolon after some class definition.
Ok I put the headers back in and looked through my Product.h code, but I'm pretty sure it is ok. However, I just tried to compile my main.cpp code again and I got the following errors.
main.cpp:(.text+0x1b): undefined reference to `Store::Store(char const*)'
main.cpp:(.text+0x2a): undefined reference to `Store::print()'
main.cpp:(.text+0x3e): undefined reference to `Store::processOrders(char const*)'
main.cpp:(.text+0x4d): undefined reference to `Store::print()'
#ifndef STORE_H
#define STORE_H
#include "Product.h"
//*****************************************************************
// FILE: Store.h
// PURPOSE: Contains the declaration for the Store class.
//*****************************************************************
class Store
{
private:
// Data members
Product productArray[30];
int numOfProducts;
public:
// Method prototypes
Store();
Store(constchar*);
int getNumOfProducts();
void sortProducts();
int searchForProduct(char*);
void processOrders(constchar*);
void print();
};
#endif