Helo frndz,

I'm a nob in c++....So, I want to know about default constructor. How to create? Why default constructor? How to create a no-arg constructor that creates a default triangle??...Plz help...

Thnx...

Recommended Answers

All 3 Replies

The default constructor is just used when no other constructors have been declared. To create a no-arg constructor (override the default constructor):

class MyClass {
public:
    MyClass();
};

MyClass::MyClass() {
    //some code...
}

The default constructor is simply the one which take no args.

Thnx nmaillet & Asafe...Thnx for Ur help...:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.