Bit shifting not working

Hey guys i hate this weird issue that i just cant seem to solve and it's driving me crazy. Im making my first project for the Arduino which will use classes/self made library. I made a function to shift my bit in a 74HC595 register. I will have to make a custom function to clock 9 registers at the same time, but decided first to make a prototype made of 1 register. When i use the code below it all works nicely, making the LEDs at the end of the register run on and off.

 digitalWrite(latch1, LOW);
 digitalWrite(clk1, LOW);
 digitalWrite(data1, HIGH);
 digitalWrite(clk1, HIGH);
 digitalWrite(latch1, HIGH);
 delay(500);
    
 digitalWrite(latch1, LOW);
 digitalWrite(clk1, LOW);
 digitalWrite(data1, LOW);
 digitalWrite(clk1, HIGH);
 digitalWrite(latch1, HIGH);
 delay(500);

However when i use a method from my library it doesn't respond at all. This is what I made so far for the library (below). Can someone tell me what's the dumb thing im doing here?It looks like the whole thing freezes and nothing moves, just stays in its last state before the new code was uploaded and started. I never programmed in Arduino before and don't know the fine details, I just know the standard C++ and Java. Thx in advance!

class Reg{
  private:
  int clockPin;
  int latchPin;
  int dataPin;

  public:
  Reg(int clk, int latch, int data);
  void shift(boolean a);
  void reset();
  void show();
};

Reg::Reg(int clk, int latch, int data){
  pinMode(clk, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(data, OUTPUT);

  digitalWrite(clk, 0);
  digitalWrite(latch, 0);
  digitalWrite(data, 0);

  reset();
}

void Reg::shift(boolean a){
  digitalWrite(latchPin, LOW);
  digitalWrite(clockPin, LOW);
  if(a){
    digitalWrite(dataPin, HIGH);
  }else{
    digitalWrite(dataPin, LOW);
  }
  digitalWrite(clockPin, HIGH);
  digitalWrite(latchPin, HIGH);
}

void Reg::reset(){
  for(int i = 0; i < 8; i++){
    shift(0);
  }
}

void Reg::show(){
  digitalWrite(this->latchPin, HIGH);
  digitalWrite(this->latchPin, LOW);
}

Reg reg1(clk1, latch1, data1);
Reg reg2(clk2, latch2, data2);

void setup() {
}

void loop() {
  reg1.shift(1);
  delay(500);
  reg1.shift(0);
  delay(500);
}

EDIT: BTW im aware that the code doesn't use its full functionality and some things are reduntant like the initialization in the constructor. Its a work in progress and first want to know why its not working at all.

You have declared a number of private variables

  private:
    int clockPin;
    int latchPin;
    int dataPin;

but they are never given any values in the program

Did you mean to copy the parameters passed to the constructor to the private variables ?

Note too that it is not a good idea to use pinMode() in the constructor as at that time the hardware may not be fully initialised. It is more normal to have a begin method to set the pinMode()s and call it from setup()

Oh wow totally forgot to assign the parameters from my constructor to the private variables how stupid of me.

And i'm not quite sure i get the idea of the begin() method. Could i just maybe assign the pinMode() in the setup() if i already know which pins will be assigned to which register? I guess thats simpler, i just wanted to do it the old fashioned C way, but seems there are technical issues with that in the Arduino.

EDIT: Also was wondering if such a code would be a valid way of making things faster.

void setup() {
  for(int i = 2; i < 8; i++){ // using pins from 2 to 7
    pinMode(i, OUTPUT); 
  }
}

It is easier to show than to describe

Untested code

class Reg
{
  private:
    int _clockPin;
    int _latchPin;
    int _dataPin;

  public:
    Reg(int clk, int latch, int data);
    void begin();
    void shift(boolean a);
    void reset();
    void show();
};

Reg::Reg(int clk, int latch, int data)
{
  _clockPin = clk;
  _latchPin = latch;
  _dataPin = data;
}

void Reg::begin()
{
  pinMode(_clockPin, OUTPUT);
  pinMode(_latchPin, OUTPUT);
  pinMode(_dataPin, OUTPUT);
  digitalWrite(_clockPin, 0);
  digitalWrite(_latchPin, 0);
  digitalWrite(_dataPin, 0);
  reset();
}
Reg reg1(clk1, latch1, data1);
Reg reg2(clk2, latch2, data2);

void setup()
{
  reg1.begin();
  reg2.begin();
}

i just wanted to do it the old fashioned C way, but seems there are technical issues with that in the Arduino.

I don't understand what you mean by this

Ah i see it makes sense. Thank you so much for clearing all of this up. I have it up and working as it should.

Topic can be closed.

Topic can be closed.

Edit your original post and add [Solved] to the title so that it is there for future reference