Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
member initial list
//g++ 5.4.0 #include <iostream> using std::cout; class Obj{ public: Obj(){ cout<<"call default ctor\n"; } Obj(const Obj& c){ cout<<"call copy ctor\n"; } Obj(int val){ cout<<"call other ctor\n"; } ~Obj(){ cout<<"destroy obj\n"; } }; class Test : public Obj // inherit from Obj { // 3 member Obj a; Obj b; Obj c; public: Test() // this ctor construct base class by Obj(), and members from a to c by Obj() { cout<<"Test call default ctor\n"; } Test(int val) :Obj(val), // construct base class by Obj() a(), // construct by Obj() b(val), // construct by Obj(int val) c(this->b) // construct by Obj(const Obj& c) { cout<<"Test call other ctor\n"; } }; int main() { Test a; // would call default ctor. cout<<"-----------------------\n"; Test b(); // would call defalt ctor, but not construct any object. cout<<"-----------------------\n"; Test c(10); // would call Test(int). cout<<"-----------------------\n"; Test* d = new Test(); // call Test(). cout<<"-----------------------\n"; Test* e = new Test(10); // call Test(int). cout<<"-----------------------\n"; }
run
|
edit
|
history
|
help
0
C++ Solar eclipse program(Shoushi integrated) 1644 - 1785 from Ideone( Date: August 14, 2014 )
constructing object on first use as return value of (pointer to) object-returning function
code
compile-time check of existness of method of a class
CutRod(BottomUp)
decode
Graph DFS
Patara asoebi
Minimum Vertices to Traverse Directed Graph
26 და 28 მარტს დამუშავებული