some changes ; mostly new examples
This commit is contained in:
20
OOP/constructor/constructor.cpp
Normal file
20
OOP/constructor/constructor.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
|
||||
/*
|
||||
Here we have a example of a Constructor ;
|
||||
When we create a Class Object we auto-call the Constructor
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MyClass {
|
||||
public:
|
||||
MyClass() { // This is the constructor!
|
||||
cout << "Construct!";
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
MyClass classobj; // When we create this the Constructor autocalls!
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user