Unsolved Assign new class constructed to an existing class member?
-
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 }
-
Your code can not compile.
-
@Christian-Ehrlicher I haven't coded yet, thinking on paper.
-
Then take a C++ book and read :)
-
@Christian-Ehrlicher That's what I'm doing now actually, got time during a lockdown. Figured I'd ask here first.
-
classTest.h private: ClassToConstruct *classToConstruct = nullptr; classTest.cpp void classTest::myMethod() { classToConstruct = new ClassToConstruct(); }
-
@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.
-
@Christian-Ehrlicher I've dabbled in it on and off during my college days. Figured I'd get back into it.