Passing LiquidCrystal reference

Hello,

I apologize, im new to this whole idea of classes and I am having some issues.

I currently have writen this class called Beer. It is responsible for printing out various states on the current beer being drank. I am attaching the sketch, source and header files for beer and the output.

If I declare LiquidCrystal lcd(some pins here), I would like my class Beer to be able to write to the lcd using that reference. So far this is where I have gotten.

I am posting everything, but I only need help with passing the LCD reference. Thanks in Advance

sketch:

//Libraries
// include the library code:
#include <LiquidCrystal.h>
#include <Beer.h>

//Initiallization
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Beer beer(0,6,12, lcd);

void setup()
{
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("90 Minute IPA");
}

void loop()
{
  int sensor = analogRead(A0);
   
   
  int bottles = map(sensor,0,1023,0,50);
  int vol = map(sensor,0,1023,0,100);
  int temp = map(sensor,0,1023,20,50);
  beer.writeBeer(bottles);
  beer.writeTemp(temp);
  beer.writeVol(vol);
   
   
   delay(75);

header for beer class:

#ifndef Beer_h
#define Beer_h

#include "Arduino.h"
#include <LiquidCrystal.h>

class Beer
{
  public:
    Beer(int Loc1, int Loc2, int Loc3, LiquidCrystal lcd);
    void writeBeer(int bottles);
    void writeTemp(int temp);
	void writeVol(int vol);
  private:
    int lastBeer;
	int lastTemp;
	int lastVol;
	
	int _beer;
	int _vol;
	int _temp;
	
	byte temp[8];
	byte beer[8];
	byte frown[8];
	byte smiley[8];
	
	LiquidCrystal refLcd;
};

#endif

source file for beer:

#include "Arduino.h"
#include "Beer.h"
#include <LiquidCrystal.h>

Beer::Beer(int Loc1, int Loc2, int Loc3, LiquidCrystal lcd)
{
	refLcd = lcd;
	//initialized for first pass
	lastBeer = -1;
	lastTemp = -1;
	lastVol = -1;
	
	//pointers to beer locations on display
	_beer = Loc1;
	_temp = Loc2;
	_vol = Loc3;
	
	byte temp[8] = 
	{
	  0b00111,
	  0b00101,
	  0b00111,
	  0b00000,
	  0b11110,
	  0b10000,
	  0b11100,
	  0b10000
	};
	byte bottles[8] = 
	{
	  0b00000,
	  0b00111,
	  0b11111,
	  0b10111,
	  0b10111,
	  0b11111,
	  0b00111,
	  0b00000
	};

	byte frown[8] = 
	{
	  0b00000,
	  0b00000,
	  0b00000,
	  0b01010,
	  0b00000,
	  0b00000,
	  0b01110,
	  0b10001
	};

	byte smiley[8] = 
	{
	  0b00000,
	  0b00000,
	  0b00000,
	  0b01010,
	  0b00000,
	  0b10001,
	  0b01110,
	  0b00000
	};

	//Create Characters
	refLcd.createChar(1,bottles);
	refLcd.createChar(2,temp);
	refLcd.createChar(3,frown);
	refLcd.createChar(4,smiley);
}

void Beer::writeBeer(int bottles)
{
  if(bottles != lastBeer)
  {
     refLcd.setCursor(_beer,1);
     refLcd.write(1);
     refLcd.print("  ");
     refLcd.setCursor((_beer+1),1);
     refLcd.print(bottles);
  }
  lastBeer = bottles;
}

void Beer::writeTemp(int temp)
{
  if(temp != lastTemp)
  {
    refLcd.setCursor(_temp,1);
	refLcd.write(2);
    refLcd.print("   ");
    refLcd.setCursor((_temp+1),1);
    refLcd.print(temp);
  }
  lastTemp = temp;
}

void Beer::writeVol(int vol)
{
  if(lastVol != vol)
  {
    refLcd.setCursor(_vol,1);
    refLcd.print("    ");
    refLcd.setCursor(_vol,1);
    if(vol > 50)
    {
      refLcd.write(4);
      refLcd.print(vol);
      refLcd.print("%");
    }
    else
    {
      refLcd.write(3);
      refLcd.print(vol);
      refLcd.print("%");
    }
  }
  lastVol = vol;
}

Output:

C:\Users\Chasen Peters\Documents\Arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\Beer\Beer.cpp: In constructor 'Beer::Beer(int, int, int, LiquidCrystal)':
C:\Users\Chasen Peters\Documents\Arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\Beer\Beer.cpp:7: error: no matching function for call to 'LiquidCrystal::LiquidCrystal()'
C:\Users\Chasen Peters\Documents\Arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal/LiquidCrystal.h:56: note: candidates are: LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
C:\Users\Chasen Peters\Documents\Arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal/LiquidCrystal.h:54: note:                 LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
C:\Users\Chasen Peters\Documents\Arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal/LiquidCrystal.h:52: note:                 LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
C:\Users\Chasen Peters\Documents\Arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal/LiquidCrystal.h:49: note:                 LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
C:\Users\Chasen Peters\Documents\Arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal/LiquidCrystal.h:45: note:                 LiquidCrystal::LiquidCrystal(const LiquidCrystal&)

You could pass lcd by reference.

class Beer
{
  public:
    Beer(int Loc1, int Loc2, int Loc3, LiquidCrystal & lcd); 
...

    LiquidCrystal & refLcd;
};

Note the & symbols in two places.

Then pull in the reference in the constructor.

Beer::Beer(int Loc1, int Loc2, int Loc3, LiquidCrystal & lcd) : refLcd (lcd)
{
    //initialized for first pass
    lastBeer = -1;
    lastTemp = -1;
    lastVol = -1;

Note the removal of the assignment, and the extra initialization on the first line.

...

Then pull in the reference in the constructor.

Beer::Beer(int Loc1, int Loc2, int Loc3, LiquidCrystal & lcd) : refLcd (lcd)
{
    //initialized for first pass
    lastBeer = -1;
    lastTemp = -1;
    lastVol = -1;

Note the removal of the assignment, and the extra initialization on the first line.

I had just started to play with the pointers after I posted. It would seem that the initialization (:refLcd (lcd)) was eluding me. The code works exactly how I would like it to now. Thank you so very much. You were very helpful.