Forum Replies Created

Viewing 15 posts - 16 through 30 (of 55 total)
  • Author
    Posts
  • in reply to: Member functions of Singleton class #547804
    Driton Kuci
    Participant
        Up
        0
        Down
        ::

        Thanx Rainer for the explanation and the example.

        I was confused, due to the static variable which holds the instance itself.

        in reply to: const pointer containg const #542461
        Driton Kuci
        Participant
            Up
            1
            Down
            ::

            As you mentioned the pointer p is const per se and it is pointing to a const integer. Therefore you can are neither change the value (through *p) nor the address it is point to (through p).
            In both cases you get almost the same error: “error: assignment of read-only location ‘*(const int*)p'” and “error: assignment of read-only variable ‘p'”, check it here: https://godbolt.org/z/eE6dMeshs

            P.S. I wanted to reply directly to the message from Antonella but the Forum tool placed my text as the last one in the order.

            in reply to: DJ Project #502081
            Driton Kuci
            Participant
                Up
                0
                Down
                ::

                Hi Rainer,

                Would be good to hear/see what they are doing and to know what he exactly wants/needs: a designer, developer or reviewer/tester.

                You can send him my Email address.

                Best Regards

                 

                 

                in reply to: Return preserves const? #488748
                Driton Kuci
                Participant
                    Up
                    0
                    Down
                    ::

                    Sorry for the late answer. I meant you return a reference of an object/variable which will not exist anymore as you would try to use it. Rainer already explained it through his example.

                    You will get more details about that in weeek 9.

                    in reply to: Adding char + int #484356
                    Driton Kuci
                    Participant
                        Up
                        1
                        Down
                        ::

                        It is correct. The provided char value is promoted/converted to its integral value due to the operator+ which requires two integral operands to sum them up. You can place your code in CPP-Insides and see this static_cast.

                        You get the warning because a char (single qoutation marks) can have only one letter, because it occupies only one Byte in memory.

                        You get the error when you use the string because is not convertible to a number.

                         

                        in reply to: Return preserves const? #484355
                        Driton Kuci
                        Participant
                            Up
                            1
                            Down
                            ::

                            I think the constness is removed from the return type because auto decays, i.e., the constness any reference or pointer is removed from variable defined as auto.

                            Just specifying the return value as const does not bring any benefit with it. Only if you return a const& then it is important/interesting, but be aware of the lifetime of the object/variable you are returning the const& from.

                            in reply to: Industries and projects #470830
                            Driton Kuci
                            Participant
                                Up
                                0
                                Down
                                ::

                                I am currently working in the IT/financial branch. We do integrate different payment terminals in our product and provide an standard API to the ECR softwares.

                                I worked as well in another company where we developed algorithms and services in GNSS (GPS, Galileo and Glonas) and telecommunication.
                                At both companies I worked (still working) as C++ developer being responsible for product/service design, implementation, testing, etc.

                                in reply to: Ping pong exercise #457271
                                Driton Kuci
                                Participant
                                    Up
                                    1
                                    Down
                                    ::

                                    I think it can happen. You can simulate this behaviour if you put a sleep( 2s ) between the two threads in main function (so let just one thread run for a time).
                                    Here you have the code example: https://godbolt.org/z/9b9rx67hs where first thread locks “only” twice the mutex. I mean, it cannot happen three times.
                                    A screenshot of the output which shows the same thread locking twice and the other one locking afterwards.

                                    But since the critical region is protected (additionally) by the predicate (dataReady == false), then the thread setTrue cannot enter this area and modify the counter again.
                                    When the predicate returns false, then the condition variable (condVar1) releases the locked mutex and takes a nap. Therefore, the other thread can lock the mutex and enter its crititcal region, where it can change the value of dataReady

                                    in reply to: Type deduction: auto vs auto* (+/- const) #412140
                                    Driton Kuci
                                    Participant
                                        Up
                                        0
                                        Down
                                        ::

                                        The simple rule to remember this is:

                                        1. If the const is at the left side of the asterisk symbol, then the data you are pointing to is constant and cannot be changed
                                        2. If the const is at the right side of the asterisk symbol, the pointer itself is constant.

                                        I hope this would help you.

                                        in reply to: Testing Private Parts of a shared Library #376335
                                        Driton Kuci
                                        Participant
                                            Up
                                            0
                                            Down
                                            ::

                                            Hi Kevin,

                                            We also built a static version of our library in order to expose everything of it and being able to do the tests.

                                            Please share the answer of Mr. Brand in this thread. Maybe he would suggest something interesting.

                                            in reply to: How does (std::cin >> x) or (std::cout << x) work #219732
                                            Driton Kuci
                                            Participant
                                                Up
                                                1
                                                Down
                                                ::

                                                I found the answer: press Ctrl + D in Linux or Ctrl + Z in Windows to provide the EOF char through the keyboard.

                                                in reply to: How does (std::cin >> x) or (std::cout << x) work #219731
                                                Driton Kuci
                                                Participant
                                                    Up
                                                    0
                                                    Down
                                                    ::

                                                    But can we stop this while loop from the keyboard by providing any special character?
                                                    Or should we implement something like this inside of it?

                                                        while (std::cin >> ch)
                                                        {
                                                            std::cout << ch;
                                                            if ('q' == ch) break;
                                                        }
                                                    
                                                    in reply to: Wrong and missing videos from week 26 #165358
                                                    Driton Kuci
                                                    Participant
                                                        Up
                                                        0
                                                        Down
                                                        ::

                                                        Thanx Rainer,

                                                        but the videos of the section Replace are still broken.

                                                        I get this error when I want to watch them:

                                                        in reply to: Wrong video for the lesson “string.cpp” #115101
                                                        Driton Kuci
                                                        Participant
                                                            Up
                                                            0
                                                            Down
                                                            ::

                                                            Hi again,

                                                            the video is wrong in this lesson: https://www.modernescpp.org/topics/example-stringcversusc-cpp/

                                                            and here it is missing: https://www.modernescpp.org/topics/example-stringnumericconversions-cpp/

                                                            Thanx for fixing them!

                                                            in reply to: Data races by parallel STL #113029
                                                            Driton Kuci
                                                            Participant
                                                                Up
                                                                0
                                                                Down
                                                                ::

                                                                To avoid reallocating the elements, I calles rehash at the beginning. Therefore there are as much buckets as elements to be added and loadFactor = 1.

                                                                Theoritically each thread should generate in-place an element and place it to the corresponding bucket. This is what makes me thinking that, even the map is shared among all threads, every thread “knows” how to behave and should not effect the others.

                                                              Viewing 15 posts - 16 through 30 (of 55 total)