Thread: C++++

  1. #16
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Stoned_Coder
    firstly if you want to you can always statically bind just by using an object instead of a pointer. Then you have static binding. Are you too lazy to simply dereference a pointer if you want static binding?
    Not true!

    Sure you can just use an object, but in most cases, that is not an option IE dynamic memory allocation.

    You can't just dereference a pointer and expect the member function to be statically bound. When you dereference a pointer and call a member function on it, it is STILL dynamically bound if the member function is virtual. It's not a matter of laziness it's a matter of it being not possible in C++.

  2. #17
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    well it wasnt when i learnt c++.
    Dynamic binding occurs on pointers and references only. Static binding on objects was how i was taught. Admittedly ive never tried it out as ive never needed to statically bind a virtual function.Must fire up the compiler and play around and see.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #18
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Stoned_Coder
    well it wasnt when i learnt c++.
    Dynamic binding occurs on pointers and references only. Static binding on objects was how i was taught. Admittedly ive never tried it out as ive never needed to statically bind a virtual function.Must fire up the compiler and play around and see.
    Static binding is and always has been used on objects. However, dereferencing a pointer is quite different from working directly with the object. Dereferencing is actually more closely related to using the pointer as a reference for that particular expression.

  4. #19
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    Does this strike a point???

    "The first thing we do, let's kill all the language lawyers"
    -- Henry VI, part II
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  5. #20
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by Stoned_Coder

    Threads should not be part of c++ in my opinion. They are a function of the operating system and so belong in an API.Adding them to c++ would in no way make multithreaded programming any simpler except maybe a little less coding required especially if you target more than one operating system.
    That reason is sufficient, IMO.
    Bleh, The C++ standard library is fine how it is. [...]
    I think the standard is large enough and does it's job fine.
    I think lots of functionality is missing. And I'm also fairly certain that the standard library WILL be extened in the future, judging from the discussion in some newsgroups.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  6. #21
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    Originally posted by Shadow12345
    What changes would YOU like to see made to C++?
    I've heard that some lang such as Ada, used in US Military, supports REAL TIME PROGRAMMING. That is not supported by C++, but I'm not sure.
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  7. #22
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    What does someone mean when they say Real Time Programming? Isn't that more of a feature of the OS?

  8. #23
    Shadow12345
    Guest
    I've heard that some lang such as Ada, used in US Military, supports REAL TIME PROGRAMMING. That is not supported by C++, but I'm not sure.
    What do you mean real time programming

    I was thinking about what I would like to see, and I think there should be different types of classes. In some applications it is very appropriate to use classes and object oriented programming, but it is also approrpiate to only declare one instance of it. There should be a type of class that automatically generates a single instance of that class and no more are allowed to be created. C++ already somewhat caters to this because when you are creating the class prototypes you can create the first instance of it, if im not mistaken, such as:
    class _blah{
    //stuff!
    } blah;

    One example of an application that would use this new type of class would be the camera class used in first person shooters. Realistically you only create one camera, because usually you only have one view. There would be exceptions to this however (there are exceptions to everything)

    1instanceclass blah{
    //stuff!
    };
    ...
    blah.dostuff() //single instance of class already created
    blah blah1; //would be illegal, single instance already exists

    well that's my idea, i dunno, im pretty happy with C++ as it is as a whole

  9. #24
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    That seems a bit radiculous. If you want just once instance of your class, just make one. Nothing is stoping you from making a global class. Things get complicated when you want to derive a class from your once instance. Are you going to limit that derived class to one instance too?

    Classes, to me, seem very generic and multipurpose how they are now. Adding more specialized datatypes to suit that onetime you might need something special seems a bit beyond what the standard is made for. Prove I'm worng, please.

  10. #25
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    Originally posted by Shadow12345
    What do you mean real time programming
    As I've heard REAL TIME PROGRAMMING is that several functions work simultaneously, and they can synchronize one another without global variables. BUT I'M STILL NOT SURE.
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  11. #26
    Registered User
    Join Date
    Jan 2003
    Posts
    311
    c++ is an assembler on steroids to which the deluxe gadget package as been added. I really like it this way. The only addition I could see is adding some elements of boost(likely) and, most importantly, a packaging system (as mentioned previously) In particular templates need to compile much much faster.

    Beyond that, threads, sockets, GUI's, IPC, reflection, etc... are all things that belong in libraries. Each involves many trade-offs that are exactly the thing you use a low-level language to control. Want a better high level language that includes this kind of thing? Use Ada. Ada genuinely forces you to write better, safer programs. As a result, using it is about as much fun as learning to drive in a Volvo with your mother, Ralph Nader, and Andy Rooney. Ada complains constantly about what you are doing, and most infuriatingly, it's usually got a point.

  12. #27
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Shadow12345: Take a look at namespaces, they behave like one-instance classes.
    The difference is that "::" is used instead of ".".
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  13. #28
    Registered User
    Join Date
    Jan 2003
    Posts
    311
    Real time programing means that you can shedule an Ada task to run at a particular time and finish in a particular time. This tends to be important for things like checking to see if the pilot has made any input changes in the last ms, choppy "frame rates" are generally unacceptable on a 777.

  14. #29
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    no use somebody elses singleton class or if you understand the problems with making one make your own singleton class.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  15. #30
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Agreed, use a singleton if you want a single instance. Using "a namespace as one instance of a class" is no better than just using global variables. A namespace has very few similarities to a class. The fact that you can use somewhat similar syntax in certain cases does not change that. Namespaces are for organization and avoiding name conflicts etc. They do not act as datatypes.

Popular pages Recent additions subscribe to a feed