Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to call a member function of multiple objects just by 1 calling?



  • Hey bros,
    I have a class named "myclass". This class has a member function : void func();
    I make an array of objects on the heap:

    myclass* cl=new myclass [10];

    I wanna call myclass::func() of all objects just by 1 time calling.

    But when i define the function as STATIC,: static void func(); i encounter an error that the function has no static members. how can i solve the problem because i have update() (for QPainter) function in func() that can not be defined as static.
    What is a remedy??
    Thanks a lot.


  • Lifetime Qt Champion

    Hi,

    You can't, you have to use a for or while loop to call your function on each object.


Log in to reply