Static Functions in C++

前端 未结 8 1315
野趣味
野趣味 2021-01-17 08:09

I\'ve read a few posts on here about static functions, but still am running into trouble with implementation.

I\'m writing a hardcoded example of Dijkstra\'s algorit

8条回答
  •  渐次进展
    2021-01-17 08:45

    You should call it this way:

    Alg::dijkstra();
    

    Limitations

    • Can't call any other class functions that are not static.
    • Can't access non static class data members.
    • Can instantiate an object via new class() when constructor is private/protected. E.g. a factory function.

提交回复
热议问题