array in library

Hi, finally i solve the array problem but I have another, i don’t know why the Arduino code does not work with for bucle, and line by line yes.

This is my Arduino code:

#include <IC_74HC4051.h>

//IC_74HC4051(int S0, int S1, int S2, int Z); 
IC_74HC4051 ic4051(5,6,7,0);

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int* value;
//  change from here
  Serial.print("Y0: ");
  value = ic4051.Read();
  Serial.println(value[0]);
  Serial.print("Y1= ");
  value = ic4051.Read();
  Serial.println(value[1]);
  Serial.print("Y2= ");
  value = ic4051.Read();
  Serial.println(value[2]);
  Serial.print("Y3= ");
  value = ic4051.Read();
  Serial.println(value[3]);
  Serial.print("Y4= ");
  value = ic4051.Read();
  Serial.println(value[4]);
  Serial.print("Y5= ");
  value = ic4051.Read();
  Serial.println(value[5]);
  Serial.print("Y6= ");
  value = ic4051.Read();
  Serial.println(value[6]);
  Serial.print("Y7= ");
  value = ic4051.Read();
  Serial.println(value[7]);
//  to here for the next
//  for (int i=0; i<=8; i++)
//  {
//    Serial.print("Y");
//    Serial.print(i);
//    Serial.print("= ");
//    value = ic4051.Read();
//    Serial.println(value[i]);
  }
  delay(1000);
}

This is my library file h:

/*************************************************************************
**  Device: 74HC4051 8-channel analog multiplexer/demultiplexer       	**
**  File:   IC_74HC4051.h   				          	**
**									**
**  Created by G. Mouriño 2014-02-18                           		**
**									**
**  Code license: CC-BY-SA						**
**  http://creativecommons.org/licenses/by-sa/3.0/             		**
**                                                                  	**
**************************************************************************/

#ifndef IC_74HC4051_h
#define IC_74HC4051_h

#include "Arduino.h"   //Arduino IDE >= V1.0


class IC_74HC4051
{
 public:
  // Constructor
  IC_74HC4051(int S0, int S1, int S2, int Z);   		
  int* Read();
  void Write(int Y0, int Y1, int Y2, int Y3, int Y4, int Y5, int Y6, int Y7);

 private:
  int _SELECT0_Pin;
  int _SELECT1_Pin;
  int _SELECT2_Pin;
  int _COMMON_Pin;
};

#endif

And this is my library file cpp:

/*************************************************************************
**  Device: 74HC4051 8-channel analog multiplexer/demultiplexer       	**
**  File:   IC_74HC4051.cpp   				          	**
**									**
**  Created by G. Mouriño 2014-02-18                           		**
**									**
**  Code license: CC-BY-SA						**
**  http://creativecommons.org/licenses/by-sa/3.0/             		**
**                                                                  	**
**************************************************************************/

#include "Arduino.h"
#include "IC_74HC4051.h"

//************************************************************************
// Constructor
IC_74HC4051::IC_74HC4051(int S0, int S1, int S2, int Z)
{	
 _SELECT0_Pin = S0;
 _SELECT1_Pin = S1;
 _SELECT2_Pin = S2;
 _COMMON_Pin = Z;

 pinMode(_SELECT0_Pin, OUTPUT);
 pinMode(_SELECT1_Pin, OUTPUT);
 pinMode(_SELECT2_Pin, OUTPUT);
}

//************************************************************************

void IC_74HC4051::Write(int Y0, int Y1, int Y2, int Y3, int Y4, int Y5, int Y6, int Y7)
{
 pinMode(_COMMON_Pin, OUTPUT);
 for (int i=0; i<8; i++)
 {
  if (i == 0)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, LOW);
   analogWrite(_COMMON_Pin, Y0);
  }
  else if (i == 1)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, LOW);
   analogWrite(_COMMON_Pin, Y1);
  }
  else if (i == 2)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, LOW);
   analogWrite(_COMMON_Pin, Y2);
  }
  else if (i == 3)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, LOW);
   analogWrite(_COMMON_Pin, Y3);
  }
  else if (i == 4)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, HIGH);
   analogWrite(_COMMON_Pin, Y4);
  }
  else if (i == 5)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, HIGH);
   analogWrite(_COMMON_Pin, Y5);
  }
  else if (i == 6)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, HIGH);
   analogWrite(_COMMON_Pin, Y6);
  }
  else if (i == 7)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, HIGH);
   analogWrite(_COMMON_Pin, Y7);
  }
 }
} 
//************************************************************************
int* IC_74HC4051::Read()
{
 pinMode(_COMMON_Pin, INPUT);
 int data[7];
 for (int i=0; i<8; i++)
 {
  if (i == 0)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, LOW);
   int Y0 = analogRead(_COMMON_Pin);
   data[0] = Y0;
  }
  else if (i == 1)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, LOW);
   int Y1 = analogRead(_COMMON_Pin);
   data[1] = Y1;
  }
  else if (i == 2)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, LOW);
   int Y2 = analogRead(_COMMON_Pin);
   data[2] = Y2;
  }
  else if (i == 3)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, LOW);
   int Y3 = analogRead(_COMMON_Pin);
   data[3] = Y3;
  }
  else if (i == 4)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, HIGH);
   int Y4 = analogRead(_COMMON_Pin);
   data[4] = Y4;
  }
  else if (i == 5)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, LOW);
   digitalWrite(_SELECT2_Pin, HIGH);
   int Y5 = analogRead(_COMMON_Pin);
   data[5] = Y5;
  }
  else if (i == 6)
  {
   digitalWrite(_SELECT0_Pin, LOW);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, HIGH);
   int Y6 = analogRead(_COMMON_Pin);
   data[6] = Y6;
  }
  else if (i == 7)
  {
   digitalWrite(_SELECT0_Pin, HIGH);
   digitalWrite(_SELECT1_Pin, HIGH);
   digitalWrite(_SELECT2_Pin, HIGH);
   int Y7 = analogRead(_COMMON_Pin);
   data[7] = Y7;
  }
 }
 return data;
}

What is the problem?
Thanks!!

Does your code REALLY look like that? Modify your post. Select the code. Select the #icon just above the smiley faces. Save.

Then, we can talk about your problems, where you think that you can use the declare and initialize syntax after an array is already declared (you can't) and where you think that you can assign a value to a whole array (int value[8] = ic4051.Read(); ) (you can't).

There are serious problems with the scope of variables like

int Y1 = analogRead(_COMMON_Pin);

it is only defined in the enclosing { } so outside it has no value...

Another problem. See the first post.

Because debugging a library is a bit of a pain, I try to get as much development as possible one inside a standalone sketch. Then, once that's working well, and I've given it a few days of testing and time to shake out any bugs and finalize the implementation, I convert it to a library.

Saves a lot of time later. You might want to try that approach with this one, or at least with your next library.

@virtual1 +1