When to write function inside the class and when to write functions outside the class?

when to write a function inside the class and when to write functions outside the class ??

when we were defining the vector class, functions were inside the class and now with linked list, why the functions are outside the class??

here (in linked list) we are not using class for linked list
we only use class for node
hence we make functions

in vector we make class for vector hence make function inside class

bhai thoda aur acha explanation de do !!

in Linked Lists we are making only one class which is for node
not for linked list
head of ll is not stored in linked list class
we store head only in main() and pass this to all functions
they are just function not related to class

but in vectors
we make complete vector class and write all functions inside vector

both approach are correct
function approach is simple and less complex so it is preferred