The question suggests that both classes and functions can't both be used together, this is not true. I'll cover the most basic level of functions here since the suggested duplicate question covers other benefits/uses of classes over static functions.
At the most basic level classes simply store a state so that it can be passed to and from functions. Note that examples are in C# but that should not affect the answer or understanding at all.
public IEnumerable<OrderDetail> GetOrderDetailsForDisplay(string sapCustomerID, DateTime deliveryDate, string orderType)
{
...
}
public IEnumerable<OrderDetail> GetOrderDetailsForDisplay(Order order)
{
...
}
The first function above does not use a class in its parameter list, giving us 4 parameters. The second function above just passes an order object since the parameters sapCustomerID, deliveryDate, and orderType describe an order.
Likewise, image if the function(s) above did not return a collection of OrderDetail
objects. The OrderDetail
class has many properties associated to it (see below).
public class OrderDetail
{
public long ID { get; set; }
public long OrderID { get; set; }
public int ProductID { get; set; }
public short Quantity { get; set; }
public bool IsClosed { get; set; }
public DateTime DeliveryDate { get; set; }
public DateTime BranchDeliveryDate { get; set; }
public DateTime TransferToSAPOn { get; set; }
public string CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public string ModifiedBy { get; set; }
public DateTime? ModifiedOn { get; set; }
public int? InventoryQuantity { get; set; }
public bool IsProductAvailable { get; set; }
}
So you could see how having to return this many fields/values could be tedious or difficult.
For even more information on this topic I suggest reviewing the links provided in the comments by gnat and CandiedOrange. I hope this helps answer your question at least a little bit.