Results 1 to 15 of 15

Thread: OO programming

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default OO programming

    Hello,
    I have this class:
    Qt Code:
    1. class Value {
    2. public:
    3. double _value;
    4. bool _missed;
    5. };
    6. class Feature {
    7. double _mean;
    8. vector<Value> _featVector;
    9. void computeMean() {
    10. for (int i=0; i < _featVector.size(); ++i) {
    11. sum += _featVec[i]._value;
    12. }
    13. _mean = sum / _featVec.size();
    14. }
    15. void normalize() {
    16. for (int i=0; i < _featVector.size(); ++i) {
    17. _featVec[i]._value = /*normalization equation */
    18. }
    19. }
    20.  
    21. class Datas {
    22. vector<Feature> _fet;
    23. public:
    24.  
    25. void computeMean() {
    26. for(int i=0; i < _feat.size(); ++i)
    27. _feat[i].computeMean();
    28. }
    29. void normalize() {
    30. for(int i=0; i < _feat.size(); ++i)
    31. _feat[i].normalize();
    32. }
    33. //main.cpp
    34. Datas data;
    35. data.computeMean();
    36. data.normalize();
    To copy to clipboard, switch view to plain text mode 
    Beyond that utility of some things, the point is: Feature is able to compute the mean and normalization on itself BUT to compute it It's necessary call it from one other class....; is it good?
    Furthermore: Will it better: class Feature : public vector<Value> { .....}

    I hope of many opinions,
    Last edited by mickey; 24th August 2008 at 18:04.
    Regards

Similar Threads

  1. Windows programming in Qt (serial communication)
    By bnilsson in forum General Programming
    Replies: 17
    Last Post: 9th February 2010, 18:17
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. QT COM Programming
    By sarav in forum Newbie
    Replies: 5
    Last Post: 24th February 2007, 13:41
  4. Using QGraphicsView with model/view programming
    By JLP in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2007, 11:04
  5. MODEL/VIEW programming
    By mira in forum Newbie
    Replies: 3
    Last Post: 21st April 2006, 11:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.