Results 1 to 8 of 8

Thread: Static methods like in Java

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Static methods like in Java

    I am making a class that can be used to get all the informations about the screencards on a PC. So we know what we can use in the DX app.

    All the information is going to be shown in a window with textboxes and combo boxes. But I was wondering. How does it work in C++. I have seen a app that does more or less that. But that app has not any class for it at all. Does that meen that I can make a headerfile with prototypes of all the functions that I need and put the functions in the cpp file and then use them the same way as static methods in Java. Or should I use a class?

  2. #2

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    BTW not sure if I made my self clear....but what I want is to not have to make a object of the class (or not class) to get all the information about the display adapters...

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    there are static methods in c++ classes too.. still i think its a bit redundant just to have a class for methods, unless you're going to use it for generic programming..
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by kedaman
    there are static methods in c++ classes too.. still i think its a bit redundant just to have a class for methods, unless you're going to use it for generic programming..

    No I am not going to use them for that....so maybe I am just best of with forgetting about the classes....thanks anyway....


    ØØ

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    if you just want to wrap them to avoid name clashes then you can use namespaces

    KS
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It makes perfect sense to have a global enumerator be a static member of the class it enumerates, like this:
    Code:
    class Screen {
    public:
      Capabilities getCaps();
      // etc.
    
    
      static Iterator enumerateScreens();
    };
    where Iterator follows the iterator concept and has a value type of Screen.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by kedaman
    if you just want to wrap them to avoid name clashes then you can use namespaces

    KS

    That is not the point. We are 4 Norwegians working on the project, so I guess all the function names and variable names will be in Norwegian.

  8. #8

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by CornedBee
    It makes perfect sense to have a global enumerator be a static member of the class it enumerates, like this:
    Code:
    class Screen {
    public:
      Capabilities getCaps();
      // etc.
    
    
      static Iterator enumerateScreens();
    };
    where Iterator follows the iterator concept and has a value type of Screen.

    Yeah that makes sense....I am always forgetting about Iterators. Don't unse them to much. Think I should think a bit more on them in my coding.


    OK...thanks both of you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width