Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
m Reverted edits by 197.156.122.147 (talk) to last version by Lfstevens
Line 53:
#include <iostream>
 
class student{
struct not_default_constructible {
public:
not_default_constructible() = delete; // delete default constructor
int a,b;
not_default_constructible(int x) { std::cout << "Constructed with " << x << '\n'; }
student(a=0,b=0) //default contractor
 
};
 
int main() {
not_default_constructible static_array[] =
{ 1, 2, 3 };
not_default_constructible *dynamic_array =
new not_default_constructible[3]{ 4, 5, 6 }; // C++11
}
</source>