I want to refactoring this code (default parameter using non-instantiated class)

29 Views Asked by At

my_func.h

class MyClass{
 public:
  OtherClass otherclass;
  void func();
  void func(OtherClass others);
};

my_func.cpp

#includ <my_func.h>

void MyClass::func(){
 func(this->otherclass);
}

void MyClass::func(OtherClass others){
 if(others.value.IsObject)
   func(others.value);
}

main.cpp

#include <my_func.h>

int main(){
 func();
}

I want to refactoring this code.

I want to set default parameter, so I write code like this.

but I think there is a better way.

0

There are 0 best solutions below