Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. The Lounge
  4. Class or library
Forum Updated to NodeBB v4.3 + New Features

Class or library

Scheduled Pinned Locked Moved The Lounge
2 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isaacEnrique
    wrote on last edited by
    #1

    Greetings.

    I am working with Qt + OpenCV. However, my question is can qualify rather as a general question about OOP (and for that reason I put it in this forum section)

    I am currently writing a class that implements a series of morphological operations that are not in openCV (like erosion and dilation geodesic among others).

    Given the characteristics of what I want to develop (or I'm developing) the class has only static member functions, and this is my question:

    My class is just a collection of functions (all static), more like a library. So, I have a doubt which is the best approach to work in this case:

    1. Just like that as I did ... a class with no attributes and only static member functions.

    2. A library of functions (style C)

    3. Any other approach more efficient or appropriate.

    I must say that I choose the first option (1) because I'm working with C++, Qt and C++ API of OpenCV (all Object Oriented), but obviously, I was not sure it was the best choice to work in a case like I described.

    Furthermore, in the case of Option 1:

    Does the class constructor and destructor must have?

    Thanks in advance for any responses and/or comments.

    Isaac Pérez
    Programming is understanding.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      Hi

      Here is my take on it (my comment is based on the assumption that you need access to these functions across different classes): Since all your functions are static, you will never need to instantiate an object of your class, which means having the class in the first place is obsolete. In this instance, I would personally have used a namespace to group (what seems to me to be) a bunch of utility functions together and the reason for my decision is this:

      "How non-member functions improve encapsulation":http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197

      Hope that helps :)

      http://www.goblincoding.com

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved