# Passing object of type "Print" into function

**URL:** <https://forum.arduino.cc/t/passing-object-of-type-print-into-function/665346>\
**Category:** Programming\
**Created:** [July 13, 2020, 5:08pm UTC](https://forum.arduino.cc/t/passing-object-of-type-print-into-function/665346 "2020-07-13T17:08:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hypercubed](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@hypercubed](https://forum.arduino.cc/u/hypercubed)\
**Post date:** [July 13, 2020, 5:08pm UTC](https://forum.arduino.cc/t/passing-object-of-type-print-into-function/665346/1 "2020-07-13T17:08:55Z")

</div>

Hello  
I am using this library in my code: [GitHub - blackketter/LuaArduino: Library for adding a Lua interpreter to Arduino sketches](https://github.com/blackketter/LuaArduino) and one of the functions I need to use is called setOut(), which sets the output of the Lua interpreter to a Print type object:

```cpp
// from the library header file
void setOut(Print* p) { out = p; };

```

I have made a custom class that implements the Print class to handle the output of the Lua interpreter like so:

```cpp
class Terminal : public Print {
  public:
    size_t write(uint8_t a) {
      //custom print function
    }
  private:
    // private stuf
};
Terminal term;

```

But when I try to pass it into the setOut function I get an error:

```cpp
no matching function for call to 'Lua::setOut(Terminal&)'

```

How can I pass "term" as a "Print" type object so that any output from Lua gets passed to the Terminal object?  
Btw I am using a Feather M4

---

<div class="post-metadata">

**Author:** ![Juraj](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/juraj/32/238785_2.png) [@Juraj](https://forum.arduino.cc/u/Juraj)\
**Post date:** [July 13, 2020, 5:14pm UTC](https://forum.arduino.cc/t/passing-object-of-type-print-into-function/665346/2 "2020-07-13T17:14:30Z")

</div>

&Terminal

---

<div class="post-metadata">

**Author:** ![hypercubed](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@hypercubed](https://forum.arduino.cc/u/hypercubed)\
**Post date:** [July 13, 2020, 5:15pm UTC](https://forum.arduino.cc/t/passing-object-of-type-print-into-function/665346/3 "2020-07-13T17:15:55Z")

</div>

Thanks, that worked

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 12:38am UTC](https://forum.arduino.cc/t/passing-object-of-type-print-into-function/665346/4 "2021-05-06T00:38:53Z")

</div>

Closed on May 6, 2021, 12:38am UTC


