Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A special member function that is automatically called when an object of a class is created. Its main job is to initialize the object's data members.
class Point {
public:
int x, y;
// Parameterized Constructor
Point(int x1, int y1) {
x = x1; y = y1;
}
};
Point p(10, 20);Constructors have the SAME name as the class. They have NO return type (not even void). They are usually public.