Page 1 of 1

C++ Error: expected ‘;’ before ‘(’ token

Posted: 03 Sep 2009, 10:45
by DarkRanger
Hi guys,

I'm getting this error and I have no idea why. Could someone please help me out?

This is the full error:

Code: Select all

In file included from main.C:2:
cashier.h:16: error: expected ‘;’ before ‘(’ token
main.C: In function ‘int main()’:
main.C:41: error: ‘class Cashier’ has no member named ‘buildMeal’
make: *** [main.o] Error 1
cashier.h

Code: Select all

#ifndef CASHIER
#define CASHIER

using namespace std;

class Cashier
{
	public:
		/*
		After creating a director, this function
		is called where the particular type of
		MealBuilder passed as a parameter will
		then be used to build a meal and finally
		return it.
		*/
		Meal* buildMeal(MealBuilder*);
	
};


#endif
meal.C

Code: Select all

#include "meal.h"
#include "cashier.h"
#include "mealBuilder.h"
#include <iostream>

/*This main will not compile 
until you've created the 
following header files and
implementations.  Comment
and uncomment as you require*/
#include "BarbarianMealBuilder.h"
#include "KiddiesMealBuilder.h"
#include "CardiacMealBuilder.h"
#include "LadiesMealBuilder.h"
#include "PizzaMealBuilder.h"


using namespace std;

/*
This main is intended to test your FINAL
implementation.

You may however comment and uncomment statements 
in this main as you test your 
implementation

You may also add functionality to test
for example your implementation of the Meal
class which is not explicitly given in this
main but note that a similar main will be used
when evaluating your practical.
*/

int main()
{
	Cashier c;
	
	MealBuilder* mb1 = new BarbarianMealBuilder();
	Meal* m1;
	m1 = c.buildMeal(mb1);
	m1->printMeal();
	delete mb1;
	delete m1;
	
	/*MealBuilder* mb2 = new KiddiesMealBuilder();
	Meal* m2;
	m2 = c.buildMeal(mb2);
	m2->printMeal();
	delete mb2;
	delete m2;
	
	MealBuilder* mb3 = new CardiacMealBuilder();
	Meal* m3;
	m3 = c.buildMeal(mb3);
	m3->printMeal();
	delete mb3;
	delete m3;
	
	MealBuilder* mb4 = new LadiesMealBuilder();
	Meal* m4;
	m4 = c.buildMeal(mb4);
	m4->printMeal();
	delete mb4;
	delete m4;
	
	MealBuilder* mb5 = new PizzaMealBuilder();
	Meal* m5;
	m5 = c.buildMeal(mb5);
	m5->printMeal();
	delete mb5;
	
	delete m5;*/
	return 0;
}
I have no idea what the problem is... :( :(

Re: C++ Error: expected ‘;’ before ‘(’ token

Posted: 03 Sep 2009, 10:54
by DarkRanger
I might have found the problem... Seems I never created cashier.C :lol: :lol:

Re: C++ Error: expected ‘;’ before ‘(’ token

Posted: 03 Sep 2009, 10:57
by RuadRauFlessa
DarkRanger wrote:I might have found the problem... Seems I never created cashier.C :lol: :lol:
ROFL n00b :lol: