Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. another "everybody knows that " question on C++

another "everybody knows that " question on C++

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionlearningc++discussion
15 Posts 4 Posters 16 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    So what is "QBluetoothAddress" - value or reference? ...and how do I get the address ? text = QBluetoothAddress(addres).toString(); PS Thanks for the book reference. You shlud "find " your "k&R" hard copy is worth over $100 US

    K Offline
    K Offline
    k5054
    wrote on last edited by
    #5

    Member 14968771 wrote:

    So what is "QBluetoothAddress" - value or reference?

    Who knows? It could be a reference, a pointer or an object. e.g.

    class myClass;
    using mc = myClass &; // mc is a reference to class myClass
    // or
    using mc = myClass *; // mc is a reference to class myClass
    // or
    typedef myClass mc; // mc is a myClass object
    // or even
    using mc = myClass && // mc is a rvalue reference

    You need to check the documentation for whatever SettingsDialog::pairingDone() is to see. I tried, but googling for SettingsDialog::pairingDone did not return anything useful. Nor did looking at QBluetooth (or something similar).

    Keep Calm and Carry On

    1 Reply Last reply
    0
    • L Lost User

      Here is definition of function taken from an example: void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing) I need to verify the actual address and having a tough time understanding this "syntax". I do understand that the function parameters are "objects" but when I RTFM it really does not explain the syntax. All I get is "passing by value or by reference" - so what are the parameters actually passed to "pairingDone" ? If possible please show me how to get the address - post actual C code point me to good resource to learn something about the syntax recommend a C++ book so I can retire my "K&R" book I can do without opinions and innuendos insults or RTFM replies. Cheers

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #6

      A `QBluetoothAddress` is presumably a bluetooth device address. So a 48-bit integer essentially, but with a specific interpretation as being a bluetooth address. It being "an address" is orthogonal to being passed by reference or by value or pointers or anything like that. With the method signature being like that though, it will be passed by value.

      L 1 Reply Last reply
      0
      • L Lost User

        A `QBluetoothAddress` is presumably a bluetooth device address. So a 48-bit integer essentially, but with a specific interpretation as being a bluetooth address. It being "an address" is orthogonal to being passed by reference or by value or pointers or anything like that. With the method signature being like that though, it will be passed by value.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #7

        Here is what works. void SettingsDialog::pairingDone(QBluetoothAddress,QBluetoothLocalDevice::Pairing) { text = "SUCCERSS TASK verify address "; text += QBluetoothAddress().toString(); qDebug() <

        L 1 Reply Last reply
        0
        • L Lost User

          Here is what works. void SettingsDialog::pairingDone(QBluetoothAddress,QBluetoothLocalDevice::Pairing) { text = "SUCCERSS TASK verify address "; text += QBluetoothAddress().toString(); qDebug() <

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #8

          This: QBluetoothAddress Class | Qt Bluetooth 5.15.13[^], the key detail being:

          Quote:

          This class holds a Bluetooth address in a platform- and protocol-independent manner.

          . But your function definition is incomplete, and would more likely be something like:

          void SettingsDialog::pairingDone(QBluetoothAddress& qbaddr, QBluetoothLocalDevice::Pairing& pair)

          where qbaddr is a reference to (i.e. address of) a QBluetoothAddress object, and pair is a reference to a QBluetoothLocalDevice::Pairing object, see QBluetoothLocalDevice Class | Qt Bluetooth 6.5.0[^]. It seems to me the main issue you need to address is gaining a good understanding of C++ and its syntax. The same probably holds true for Qt and its Bluetooth classes.

          1 Reply Last reply
          0
          • K k5054

            You should have Stroustrups's "The C++ Programming Language", which is the C++ equivalent of K&R for C. [https://www.amazon.com/C-Programming-Language-4th/dp/0321563840\](https://www.amazon.com/C-Programming-Language-4th/dp/0321563840) It's not cheap, but its the bible of C++. Stroustrup invented it after all. I lost my copy of K&R a long time ago. My version was pre-ANSI, which meant that there was no void, and no function prototypes, among other things, and function definitions looked like

            foo(x, y)
            int x;
            int y;
            {
            /* function body */
            }

            I'd be willing to bet even K&R that old explained the difference between "pass by value" and "pass by reference" i.e the difference between making a copy of an object and passing that to the function (pass by value, possibly expensive), and passing a pointer to a an object (pass by reference, usually cheap. But at least in C may lead to off-by-one and other assorted bugs. NB. An array is always passed by reference.). In C++ we have references. [Reference declaration - cppreference.com] (https://en.cppreference.com/w/cpp/language/reference)

            Keep Calm and Carry On

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #9

            k5054 wrote:

            I lost my copy of K&R a long time ago. My version was pre-ANSI, which meant that there was no void,

            Well that is interesting and true. The C Programming Language First Edition : Dennis Ritchie, Brian Kernighan : Free Download, Borrow, and Streaming : Internet Archive[^] The copyright was 1978 and wikipedia states "By the time Bjarne Stroustrup began his work on C++ in 1979–1980,[citation needed] void and void pointers were part of the C language dialect supported by AT&T-derived compilers" Void type - Wikipedia[^] So even though the book didn't have it, it seems likely that it was added very shortly after the book actually went to the printers. When I was looking up the above the K&R has a 'Second Edition' but with version with pre and post ANSI C, which would seem confusing to me. I have the Pre edition. But also appears there is no edition beyond that?

            1 Reply Last reply
            0
            • L Lost User

              Here is definition of function taken from an example: void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing) I need to verify the actual address and having a tough time understanding this "syntax". I do understand that the function parameters are "objects" but when I RTFM it really does not explain the syntax. All I get is "passing by value or by reference" - so what are the parameters actually passed to "pairingDone" ? If possible please show me how to get the address - post actual C code point me to good resource to learn something about the syntax recommend a C++ book so I can retire my "K&R" book I can do without opinions and innuendos insults or RTFM replies. Cheers

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #10

              Member 14968771 wrote:

              All I get is "passing by value or by reference" - so what are the parameters actually passed to "pairingDone" ?

              That refers to how they are passed. You are asking what they are. You have a method. It takes parameters. To use the method you must do the following 1. Understand the execution flow required to use the method 2. Understand the type of the parameters. 3. Understand how to create the parameters. 4. Understand what the method does.

              Member 14968771 wrote:

              point me to good resource to learn something about the syntax

              Based on what you posted you do not have enough knowledge about C++ to begin to use the function you posted above. (Using bluetooth is not easy for an experienced programmer.) Your questions are valid but even if someone provided an exact answer you would still need more information to use everything else required to correctly use the method that you posted. But if you want you can use the following in google. Those examples do explain what the first parameter is and what to do with it. But then you need the other parameter. And everything else I mentioned above.

              QBluetoothAddress examples

              L 1 Reply Last reply
              0
              • J jschell

                Member 14968771 wrote:

                All I get is "passing by value or by reference" - so what are the parameters actually passed to "pairingDone" ?

                That refers to how they are passed. You are asking what they are. You have a method. It takes parameters. To use the method you must do the following 1. Understand the execution flow required to use the method 2. Understand the type of the parameters. 3. Understand how to create the parameters. 4. Understand what the method does.

                Member 14968771 wrote:

                point me to good resource to learn something about the syntax

                Based on what you posted you do not have enough knowledge about C++ to begin to use the function you posted above. (Using bluetooth is not easy for an experienced programmer.) Your questions are valid but even if someone provided an exact answer you would still need more information to use everything else required to correctly use the method that you posted. But if you want you can use the following in google. Those examples do explain what the first parameter is and what to do with it. But then you need the other parameter. And everything else I mentioned above.

                QBluetoothAddress examples

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #11

                I am NOT and never claim to be an expert in C++. PLEASE QUIT harassing me about my "lack of basic knowledge" - such continuing (!) harassment just does not fit this forum purpose . ( read how to answer the question INSTRUCTIONS and follow them PLEASE ) I am just learning as I go because I believe that it is better to start with coding a real application and if it does not perform as expected then RTFM and or ask for help. ( and I do not need anybody opinion contradicting my approach ) Here is what I got from Mrs Google example void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing) here is a suggestion from forum void SettingsDialog::pairingDone(QBluetoothAddress & address ,QBluetoothLocalDevice::Pairing) all I am asking - which way is up and WHY ? I know the QBluetoothAddress is / contains Bluetooth address - and that is NOT the issue.

                L J 2 Replies Last reply
                0
                • L Lost User

                  I am NOT and never claim to be an expert in C++. PLEASE QUIT harassing me about my "lack of basic knowledge" - such continuing (!) harassment just does not fit this forum purpose . ( read how to answer the question INSTRUCTIONS and follow them PLEASE ) I am just learning as I go because I believe that it is better to start with coding a real application and if it does not perform as expected then RTFM and or ask for help. ( and I do not need anybody opinion contradicting my approach ) Here is what I got from Mrs Google example void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing) here is a suggestion from forum void SettingsDialog::pairingDone(QBluetoothAddress & address ,QBluetoothLocalDevice::Pairing) all I am asking - which way is up and WHY ? I know the QBluetoothAddress is / contains Bluetooth address - and that is NOT the issue.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #12

                  Member 14968771 wrote:

                  I am NOT and never claim to be an expert in C++.

                  No one ever said you did, but your lack of understanding of the language means that you are wasting your time trying to work this project which is obviously well beyond your knowledge level.

                  Member 14968771 wrote:

                  Here is what I got from Mrs Google example void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing)

                  Where exactly did you get that, because as it stands it makes no sense?

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    Member 14968771 wrote:

                    I am NOT and never claim to be an expert in C++.

                    No one ever said you did, but your lack of understanding of the language means that you are wasting your time trying to work this project which is obviously well beyond your knowledge level.

                    Member 14968771 wrote:

                    Here is what I got from Mrs Google example void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing)

                    Where exactly did you get that, because as it stands it makes no sense?

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #13

                    OK APPARENTLY YOU LACK BOTH READING SKILLS ( READ HOW TO ANSWER THE QUESTION) AND compassion AND OF COURSE YOU CANNOT TAKE A HIT EITHER. SO I HAVE NO CHOICE BUT TO SAY THIS i HAVE NO ISSUES WITH YOUR technical KNO0WLDGE , HOWEVER I AM ASKING YOU , AS POLITELY AS I CARE , CEASE AND DESIST REPLYING WITH INSULTS AND personal OPINIONS TO MY POSTS . PERIOD. ...HAVE A GREAT DAY

                    OriginalGriffO 1 Reply Last reply
                    0
                    • L Lost User

                      I am NOT and never claim to be an expert in C++. PLEASE QUIT harassing me about my "lack of basic knowledge" - such continuing (!) harassment just does not fit this forum purpose . ( read how to answer the question INSTRUCTIONS and follow them PLEASE ) I am just learning as I go because I believe that it is better to start with coding a real application and if it does not perform as expected then RTFM and or ask for help. ( and I do not need anybody opinion contradicting my approach ) Here is what I got from Mrs Google example void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing) here is a suggestion from forum void SettingsDialog::pairingDone(QBluetoothAddress & address ,QBluetoothLocalDevice::Pairing) all I am asking - which way is up and WHY ? I know the QBluetoothAddress is / contains Bluetooth address - and that is NOT the issue.

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #14

                      Member 14968771 wrote:

                      PLEASE QUIT harassing me about my "lack of basic knowledge" - such continuing (!) harassment just does not fit this forum purpose . ( read how to answer the question INSTRUCTIONS and follow them PLEASE ) I am just learning as I go because I believe that it is better to start with coding a real application and if it does not perform as expected then RTFM and or ask for help.

                      I am not harassing you. I am however trying to make sense of what you are asking from the context of what you posted. I have about 15 years of C++ experience and with C experience before that (but quite a few years ago) along with with decades of experience in other programming language. With that experience I would expect that getting bluetooth code to work would be a challenge for me. Your lack of experience in understand fundamentals of programming, not just in C++, means that attempting to explain everything that you would need to know how to proceed with a bluetooth project is just not worth the time to even start. That is not a reflection on you. Anyone and everyone, even a super genius, would still need to know more fundamentals before they could even start. But even so I did outline exactly what you would need to do to program the project.

                      Member 14968771 wrote:

                      all I am asking - which way is up and WHY ?

                      No idea what you are asking. But my previous outline provides the framework for which you would need to proceed.

                      1 Reply Last reply
                      0
                      • L Lost User

                        OK APPARENTLY YOU LACK BOTH READING SKILLS ( READ HOW TO ANSWER THE QUESTION) AND compassion AND OF COURSE YOU CANNOT TAKE A HIT EITHER. SO I HAVE NO CHOICE BUT TO SAY THIS i HAVE NO ISSUES WITH YOUR technical KNO0WLDGE , HOWEVER I AM ASKING YOU , AS POLITELY AS I CARE , CEASE AND DESIST REPLYING WITH INSULTS AND personal OPINIONS TO MY POSTS . PERIOD. ...HAVE A GREAT DAY

                        OriginalGriffO Offline
                        OriginalGriffO Offline
                        OriginalGriff
                        wrote on last edited by
                        #15

                        You seem to be under the impression that everybody here is both out to get you and here to do your work for you: neither is the case. Unfortunately for you everybody here is a volunteer, and most do not take kindly to having their time wasted and abuse HURLED at them and respond in an appropriate manner. I hope that you can take your time here as a learning experience, but from your question and comment history, I guess that is unlikely. If this has been your attitude on the "other sites" that threw you off as well, I can understand why they didn't want you around either ...

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups