Ok so, struct is a class, but shit.

Ok so, struct is a class, but shit.

Nothing Ever Happens Shirt $21.68

DMT Has Friends For Me Shirt $21.68

Nothing Ever Happens Shirt $21.68

  1. 1 month ago
    Anonymous

    lol no?

    • 1 month ago
      Anonymous

      It's not his fault. OOP evangelists have poisoned everything and in the process completely forgot what defines OOP.

      • 1 month ago
        Anonymous

        >he thinks there's a strict definition for OOP
        If there was any, good type system would be a minimum requirement, something C will never have.

        • 1 month ago
          Anonymous

          >>he thinks there's a strict definition for OOP
          I made no such claim, because the definition has been shifting throughout time. However, nowadays people tend to think about everything in OOP terms because that's the only paradigm they are familiar with. And that is just stupid. At that point, there is no need to define OOP because it is void of meaning.

          >good type system would be a minimum requirement
          I disagree but that is beside the point.

          • 1 month ago
            Anonymous

            ok show me what OOP looks like without a good type system then

            That's not an example of inheritance. You are casting a pointer to a different struct and that's what gives you then access to the field.
            Also you embedded wo struct inside man struct. Are you implying that every man is a little girly inside?

            no idea, I don't get paid to model inheritance trees

          • 1 month ago
            Anonymous

            >what OOP looks like without a good type system
            C++ comes to mind. Enjoy.

          • 1 month ago
            Anonymous

            My bad, I forgot that cniles are too mentally ill to understand anything that's not as shit as C, disregard anything I wrote or asked.

    • 1 month ago
      Anonymous

      Yes, why would you want to use a struct instead of a class? Is just a class but limited.

      A struct is just a custom data type

      So class but worse.

      structs are useful, moron. It's just that cniles are moronic like you and don't understand that classes are useful too, just like you don't understand that structs are useful too.

      >Structs are USEFUL
      >How? I mean... They just ARE, OK!?

      In C, a struct is just a collection of data fields. It has no member functions and no inheritance, so it's hard to justify calling it a class.
      (They also have their own namespace for legacy reasons, so you need to either use the struct keyword each time you refer to them or use a typedef.)

      In C++, a struct is just a class whose members are public by default. If a struct or class contains only data fields and no constructors, virtual methods, etc then it's equivalent to a C struct and we call it a "POD type". The struct keyword quirk doesn't apply.

      So it is a shit thing that no one would bother looking at, is confusing and you are better off using classes.

      structs are just classes with some limitations. unless you're using c++ in which case they're basically the same thing with minor differences

      That's what I said. Classes, but shit.

  2. 1 month ago
    Anonymous

    A struct is just a custom data type

  3. 1 month ago
    Anonymous

    ye

    they were around before the idea of scoped access was a thing, and in order to stay compatible with c code we still have them

    • 1 month ago
      Anonymous

      >scoped access
      ironically, they had enough brain to make struct names be on a different semantic scope than variables names. You can use static global structs as sort of pseudoscopes too.

      • 1 month ago
        Anonymous

        yeah scoped access isn't the correct term but you know what i mean

        object restricted access maybe

  4. 1 month ago
    Anonymous

    structs are useful, moron. It's just that cniles are moronic like you and don't understand that classes are useful too, just like you don't understand that structs are useful too.

    • 1 month ago
      Anonymous

      i know what u mean but at the same time i dont lol

  5. 1 month ago
    Anonymous

    why C is so gay it needs second time struct keyword

  6. 1 month ago
    Anonymous

    In C, a struct is just a collection of data fields. It has no member functions and no inheritance, so it's hard to justify calling it a class.
    (They also have their own namespace for legacy reasons, so you need to either use the struct keyword each time you refer to them or use a typedef.)

    In C++, a struct is just a class whose members are public by default. If a struct or class contains only data fields and no constructors, virtual methods, etc then it's equivalent to a C struct and we call it a "POD type". The struct keyword quirk doesn't apply.

    • 1 month ago
      Anonymous

      >he thinks C has no inheritance
      #include <assert.h>
      #include <stdbool.h>
      #include <stdio.h>

      struct wo
      {
      bool is_a_woman;
      };

      struct man
      {
      struct wo woman;
      };

      int main() {
      struct man const male = {0};
      struct wo const* const troony = (struct wo const*)&male;
      assert(troony->is_a_woman);
      }

      • 1 month ago
        Anonymous

        >struct wo const* const troony
        god damn c is ugly

      • 1 month ago
        Anonymous

        Yes, you can do it manually by exploiting the fact that casting a pointer to a struct into a pointer to its first member is guaranteed to be valid. And you can roll your own vtables if you want, like COM objects do.
        That's different from formal language-level support for inheritance.

        Structs can have functions as members.
        struct shit {
        int (*func)(int ass);
        };

        A member that is a function is not the same as a "member function" (method).

      • 1 month ago
        Anonymous

        That's not an example of inheritance. You are casting a pointer to a different struct and that's what gives you then access to the field.
        Also you embedded wo struct inside man struct. Are you implying that every man is a little girly inside?

    • 1 month ago
      Anonymous

      Structs can have functions as members.
      struct shit {
      int (*func)(int ass);
      };

      • 1 month ago
        Anonymous

        which has nothing to do with member functions that don't exist in C

  7. 1 month ago
    Anonymous

    If you're only going to use one variable in the struct then you should make it a union to save memory.

    • 1 month ago
      Anonymous

      thanks anon
      and if you're not going to use negative numbers make sure to make it unsigned!

  8. 1 month ago
    Anonymous

    structs are just classes with some limitations. unless you're using c++ in which case they're basically the same thing with minor differences

  9. 1 month ago
    Anonymous

    ehhh sort of, but not really

  10. 1 month ago
    Anonymous

    structs are about data/storage, classes are about behavior
    even though they are the same thing in c++ like other anons said

Your email address will not be published. Required fields are marked *