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. Assign new class constructed to an existing class member?
Forum Updated to NodeBB v4.3 + New Features

Assign new class constructed to an existing class member?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 436 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.
  • C Offline
    C Offline
    Calicoder
    wrote on last edited by Calicoder
    #1

    Howdy, was wondering how you'd assign a newly created class to any existing member? I have this so far:

    classTest.h
    
    private:
            ClassToConstruct classToConstruct;
    
    classTest.cpp
    
    void classTest::myMethod()
    {
            *classToConstruct = new ClassToConstruct(); // this gets added to the classToConstruct class member in classTest.h
    }
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Your code can not compile.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      C 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Your code can not compile.

        C Offline
        C Offline
        Calicoder
        wrote on last edited by
        #3

        @Christian-Ehrlicher I haven't coded yet, thinking on paper.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then take a C++ book and read :)

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          C 1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            Then take a C++ book and read :)

            C Offline
            C Offline
            Calicoder
            wrote on last edited by
            #5

            @Christian-Ehrlicher That's what I'm doing now actually, got time during a lockdown. Figured I'd ask here first.

            JonBJ Christian EhrlicherC 2 Replies Last reply
            0
            • C Calicoder

              @Christian-Ehrlicher That's what I'm doing now actually, got time during a lockdown. Figured I'd ask here first.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @Calicoder

              classTest.h
              
              private:
                      ClassToConstruct *classToConstruct = nullptr;
              classTest.cpp
              
              void classTest::myMethod()
              {
                      classToConstruct = new ClassToConstruct();
              }
              
              1 Reply Last reply
              2
              • C Calicoder

                @Christian-Ehrlicher That's what I'm doing now actually, got time during a lockdown. Figured I'd ask here first.

                Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Calicoder said in Assign new class constructed to an existing class member?:

                Figured I'd ask here first.

                You should not start learning Qt before knowing the basics of c++, sorry.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                C 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  @Calicoder said in Assign new class constructed to an existing class member?:

                  Figured I'd ask here first.

                  You should not start learning Qt before knowing the basics of c++, sorry.

                  C Offline
                  C Offline
                  Calicoder
                  wrote on last edited by
                  #8

                  @Christian-Ehrlicher I've dabbled in it on and off during my college days. Figured I'd get back into it.

                  1 Reply Last reply
                  0

                  • Login

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