You believe your code isn't working because you didn't see the console output? Set a breakpoint on the return 0
and then run the code in the debugger. Wait for it to hit the breakpoint and then switch to your console window it opened. The text should be there.
C++ Inner class construction problem
Hi to all,
I can't figure out what is the problem with the following simple C++ code!
the inner RegClass class within Test class won't construct.
Any ideas?
#include <stdio.h>
class RegClass {
public:
RegClass() { printf("c-tor\r\n"); }
};
class Test {
public:
int a;
RegClass Reg;
};
int main()
{
Test t;
return 0;
}
2 answers
Sort by: Most helpful
-
Michael Taylor 54,566 Reputation points
2024-06-17T16:29:52.8166667+00:00 -
Minxin Yu 11,996 Reputation points Microsoft Vendor
2024-06-18T02:17:27.5266667+00:00 Hi, @S. Beniashvili •
The code has no errors and prints the content correctly.
If you have multiple projects in your solution, make sure the current project is the startup project.Could you attach a screenshot of a running command window without any personal privacy information?
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.