Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Use variables from file A in file B in C++
Forum Updated to NodeBB v4.3 + New Features

Use variables from file A in file B in C++

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 380 Views
  • 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.
  • T Offline
    T Offline
    TheGreenTank
    wrote on 28 Mar 2022, 15:15 last edited by
    #1

    Hello,
    I am currently working on a project and I have a problem with variables. The project is split into several independent .cpp files and I would like to retrieve variables from the first file to use them in the second file but I don't know how to do this.
    In short, I would like to use variables from file A in file B by means of a pointer pass.
    If you have any information on how to do this, I'd love to hear from you and thank you in advance !

    TheGreenTank

    J 1 Reply Last reply 28 Mar 2022, 16:06
    0
    • T TheGreenTank
      28 Mar 2022, 15:15

      Hello,
      I am currently working on a project and I have a problem with variables. The project is split into several independent .cpp files and I would like to retrieve variables from the first file to use them in the second file but I don't know how to do this.
      In short, I would like to use variables from file A in file B by means of a pointer pass.
      If you have any information on how to do this, I'd love to hear from you and thank you in advance !

      TheGreenTank

      J Online
      J Online
      JonB
      wrote on 28 Mar 2022, 16:06 last edited by
      #2

      @TheGreenTank
      Well, at the end of the day however you do it you will want to #include "A.h" into B.cpp. That will allow B to access things from A. Whatever is declared public in A.h can be accessed from B.

      P 1 Reply Last reply 28 Mar 2022, 22:44
      0
      • J JonB
        28 Mar 2022, 16:06

        @TheGreenTank
        Well, at the end of the day however you do it you will want to #include "A.h" into B.cpp. That will allow B to access things from A. Whatever is declared public in A.h can be accessed from B.

        P Offline
        P Offline
        Pueablo
        wrote on 28 Mar 2022, 22:44 last edited by
        #3

        @JonB Don't forget to declare the variables as public.

        J 1 Reply Last reply 29 Mar 2022, 08:15
        0
        • P Pueablo
          28 Mar 2022, 22:44

          @JonB Don't forget to declare the variables as public.

          J Online
          J Online
          JonB
          wrote on 29 Mar 2022, 08:15 last edited by
          #4

          @Pueablo said in Use variables from file A in file B in C++:

          @JonB Don't forget to declare the variables as public.

          ?

          @JonB said in Use variables from file A in file B in C++:

          Whatever is declared public in A.h can be accessed from B.

          1 Reply Last reply
          2

          1/4

          28 Mar 2022, 15:15

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved