Why is my program saying I didn't implement my friend insertion operator?

I'm getting a linker error, even though I'm pretty sure I implemented the friend operator correctly.
20 Replies
gr8b8m8_2l8
gr8b8m8_2l82y ago
Where's the friend keyword If you want that to be a friend
Revan
Revan2y ago
oh whoops i forgot to add that ok i put the friend keyword in my header file and i moved the declaration into the class, but im still getting the same error
Revan
Revan2y ago
Σ
Σ2y ago
I thought you just call it like os << tk ?
Revan
Revan2y ago
do you mean my declaration parameters is wrong?
Σ
Σ2y ago
So in your class, you have friend ostream& operator<< etc. Then define the ostream& operator<< externally And to call it you would just say os << tk
Revan
Revan2y ago
oh im not personally calling the operator, the main program file thats given to me is, and when i try to compile it i get an error. the message on vs code says theres not definition of the operator even though i did provide a defintion in my cpp file
Revan
Revan2y ago
gr8b8m8_2l8
gr8b8m8_2l82y ago
You can't just say os<<tk Not when you're defining what << will do Unless you made a mistake with namespaces or something it looks fine? If you zip your code and dm it I can take a closer look
Revan
Revan2y ago
yeah i can dm the code, thanks
emp0864
emp08642y ago
@revan4477 can you share you header file for TimedTask
gr8b8m8_2l8
gr8b8m8_2l82y ago
Issue was in the cpp file
Revan
Revan2y ago
thanks for all the help guys👍
Σ
Σ2y ago
It does work though
Want results from more Discord servers?
Add your server