On 2008-08-07 11:39, Pallav singh wrote:
#include<iostream.h>
#include<memory.h>
#include<string.h>
Drop the .h, it is pre-standard C++ (10 years old).
// Abstract Builder
class PizzaBuilder
{
protected :
std::auto_ptr<Pizza> pizza;
public :
PizzaBuilder(){}
virtual ~PizzaBuilder(){}
std::auto_ptr<Pizza> GetPizza(){return pizza;}
virtual void BuildTopping() = 0;
virtual void BuildSauce() = 0;
virtual void BuildDough() = 0;
std::auto_ptr<Pizza> CreateNew_PizzaProduct()
{ pizza.reset(new Pizza()); }
Actually I'm surprised your code crashes, because it should not even
compile. In the above function you forgot to return a value. It might be
possible (though it should not happen) that your compiler returns some
default value which is somehow converted to std::auto_ptr<Pizza> which
causes a crash when CreateNew_PizzaProduct is called in ConstructPizza.
--
Erik Wikstr=F6m