Sorry, but there are a number of issues. You are also using slightly non-standard grammar.
line 5
That's a class
definition, not a declaration.
line 6
"Private coding initiative" does mean anything to me? Perhaps "Private members" (as the public block includes variables and functions.)
line 10, 11
what you are doing here is initializing the variables
(Note it's better form to use the constructor initializer list for this purpose, e.g.
1 2
|
example() : a(0), b(0) {
}
|
)
line 12
you
invoke a constructor rather than provoke it
line 14
You have
defined the member function display (though you're declared it as the same time.) Compare with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
class example { // Class declared
private: // Private coding initiative.
int a, b; // declared 2 private variables.
public: // Public coding initiative
example() { // Constructor started.
a=10; // First variable under constructor
b=20; // Second variable under constructor
cout<<"This is COnstructor Block"; // Message to display when constructor provoked
}
void display(); // declare void function to display result
};
void example::display(){ // define void function to display result
cout<<"Values :"<<a <<"\t"<<b; // Display result of variable which values assigned by Constructor.
}
|
line 15
The use of the word result implies a calculation, which is not the case here. You are just displaying the values of the variables as assigned in the constructor (or set in the constructor.
line 18
You've
defined Object here (as a variable of type example.)
line 20
you've
called the function, or invoked it, but not initialized it
line 21
getch() doesn't end the program (it waits for the user to press a key)
(Note that getch is a non-standard function, from the point of view of C++, like everything else in conio.h.)
Andy
PS Might be useful for you to read?
Declarations, Prototypes, Definitions, and Implementations
http://www.cplusplus.com/articles/yAqpX9L8/