A constructor is a function defined in a class with the name same as the class name and is used to automatically initialized the class data members. It is never preceded by a return type not even void.
eg -
class abc
{
int a, b;
abc() //constructor
{
a=0;
b=0;
}
};
main()
{
abc a;
}
The time we create object of the class in the main function the data members of the class are automatically initialised.
Constructor can even take parameter. Those constructor are known as parameterised constructor.
An abstract class is any class definition that contains at least one pure-virtual function. class AbstractClass { public: virtual void DoSomething()=0; // Pure-virtual. };
A forward declaration. However forward declarations can only be used when the class is used as a pointer or reference prior to its definition, otherwise it must be defined before it is used. class A; // forward declaration class B { A& data; // reference to class that has yet to be defined }; class A {}; // definition
s.
Sure.
You have a class(i.g. MyClass): class MyClass{ public: int MyData; }; And then you use the class like this: int main(){ MyClass MyObject; MyObject.MyData=7; }
An abstract class is any class definition that contains at least one pure-virtual function. class AbstractClass { public: virtual void DoSomething()=0; // Pure-virtual. };
No.
A forward declaration. However forward declarations can only be used when the class is used as a pointer or reference prior to its definition, otherwise it must be defined before it is used. class A; // forward declaration class B { A& data; // reference to class that has yet to be defined }; class A {}; // definition
An object in C++ is an instance of a C++ class.
s.
B. Class.
In C++, methods are simply class member functions.
Sure.
class class_name { private: data_members; public: member_functions; };
la la land
A declaration is an incomplete type whereas a definition is a complete type.
An object is simply an instance of a class.