Home > Back-end >  The same code in vscode and inconsistent results in vs running above
The same code in vscode and inconsistent results in vs running above

Time:09-22

#include
#include

using namespace std;

The class Person {
Public:
The Person () {
Cout & lt; & lt; "The person the default constructor calls" & lt; & lt; Endl;
}
//a parameter constructor
The Person (int a) {
Age=a;
Cout & lt; & lt; "The person have arguments constructor calls" & lt; & lt; Endl;
}
//copy constructor
The Person (const Person & amp; P) {
//will be introduced to all attributes of the object is copied "
Age=p.age;
Cout & lt; & lt; "Person of the copy constructor calls" & lt; & lt; Endl;
}
To the Person () {
Cout & lt; & lt; "Person of the destructor call" & lt; & lt; Endl;
}

Private:
int age;
};

The Person dowork2 () {
The Person p1;
Cout & lt; & lt; & P1 & lt; & lt; Endl;
Return p1;
}
Void test03 () {
The Person p2=dowork2 ();
Cout & lt; & lt; & The p2 & lt; & lt; Endl;

}

Int main () {

Test03 ();
system("pause");
Return 0;
}

CodePudding user response:

Vscode results:
The person the default constructor calls
0 x22fe0c
0 x22fe0c
The person the destructor call

Vs the results as follows:
The person the default constructor calls
0045 f7d4
The person the copy constructor calls
The person the destructor call
0045 f8cc
The person the destructor call

CodePudding user response:

Want to know what code to run on vscode why can appear such problem, thanks to big solutions

CodePudding user response:

Set the release version to try again?
  • Related