I'm playing around with nested classes and I'm getting some rather strange output from what appears to be some rather simple numbers. Take a look at my program below.
Now I'm expecting that during the output I should see this:Code:#include <cstdlib> #include <iostream> using namespace std; class A { protected: int d; public: class SubA { protected: int a; public: SubA() {}; ~SubA() {}; int getA() { return a; } void setA(int _a) { _a = a; } }; class SubB { protected: int b; public: SubB() {}; ~SubB() {}; int getB() { return b; } void setB(int _b) { _b = b; } }; class SubC { protected: int c; public: SubC() {}; ~SubC() {}; int getC() { return c; } void setC(int _c) { _c = c; } }; A() {}; ~A() {}; int getD() { return d; } void setD(int _d) { _d = d; } }; int main(int argc, char *argv[]) { //instantiate all the classes A dummy; A::SubA subADummy; A::SubB subBDummy; A::SubC subCDummy; //set up some values dummy.setD(5); subADummy.setA(10); subBDummy.setB(15); subCDummy.setC(20); //print them out to the screen cout << dummy.getD() << endl; cout << subADummy.getA() << endl; cout << subBDummy.getB() << endl; cout << subCDummy.getC() << endl; system("PAUSE"); return EXIT_SUCCESS; }
5
10
15
20
However there's an entirely different case. This is what the output looks like:
2013315389
2013327107
2013454920
7863840
I'm having a slight problem understanding what in the world is going on here. I understand the principals of nested classes but from what I can remember when I first started with these a long time ago, I've never seen this kind of output before. Can someone give me a hand here? Thanks a lot.
[EDIT] I wonder if those first three output number are phone numbers?![]()




Reply With Quote