0

my english not good ,sorry.

clion class variable not initialized why appear z =16 and vs2019 situation not same

#include <iostream>
using namespace  std;
class  bas {
public:
    int showget();
private:
    int x, z, y;
};
int main() {

    bas B;
    B.showget();
    return 0;
}
int bas::showget() {
    cout << x << " " << " " << z << " " << y << "\n";
    int *t;
    t = &x;
    cout << t<<"\n";
    t = &y;
    cout << t<< "\n";
    t = &z;
    cout << t;
    return 0;
}
}
}

enter image description here

鹰 9am
  • 13
  • 2
  • 1
    Uninitialized means just that. Depending on what you did earlier in the function, `B` will contain different types of stack garbage. – Botje Oct 13 '20 at 09:59
  • Does this answer your question? [Unitialized Variables in C++](https://stackoverflow.com/questions/33336641/unitialized-variables-in-c) – bam Oct 13 '20 at 10:31

0 Answers0