|
| |||||||||
| Tags: binding, code, early binding, process, program |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| early binding in a C++
I am studying in T.Y.B.Sc and attending course for C++ from NIIT. In c++ there is concept called early binding which is very tough. I unable to attend lecture for this topic and now I can not understand that topic. I want to know process of early binding through code. Please give me code that based on early binding. |
|
#2
| ||||
| ||||
| Re: early binding in a C++
Using early binding direct function calls can be resolved. In early binding compiler is directly is associate with the identifier name using machine address. All function have same machine address so when the compiler calls to a function, it replace the call with machine language instruction that tells CPU to jump to the address of the function. Code: void Print(int n)
{
std::cout << n;
}
int main()
{
Print (6);
return 0;
} |
|
#3
| ||||
| ||||
| Re: early binding in a C++ Code: #include <iostream>
using namespace std;
int Add(int m, int m)
{
return m+n ;
}
int Subtract(int m, int n)
{
return m - n;
}
int Multiply(int m, int n)
{
return m * n;
}
int main()
{
int m;
cout << "Enter a number: ";
cin >> m;
int n;
cout << "Enter another number: ";
cin >> n;
int nOperation;
do
{
cout << "Enter an operation (0=add, 1=subtract, 2=multiply): ";
cin >> nOperation;
} while (nOperation < 0 || nOperation > 2);
int nResult = 0;
switch (nOperation)
{
case 0: nResult = Add(m, n); break;
case 1: nResult = Subtract(m, n); break;
case 2: nResult = Multiply(m, n); break;
}
cout << "The answer is: " << nResult << endl;
return 0;
} |
|
#4
| ||||
| ||||
| Re: early binding in a C++
Advantage of early binding is as follows- 1 Your code is run faster than late binding because it complied all things first. 2 Debugging is more faster and compiler is able to spot syntax error. 3 You have full access over a project so that you can type keyword and dot operator to get list of properties and methods. 4 You have full access to the application object via the Object browser. |
|
#5
| ||||
| ||||
| Re: early binding in a C++
The events that takes place during compile time are called early binding. This shows that all the information which is require to call function is available at compile time. The compiler decide that which method give response to the request. The accessing of member functions of a class using pointer is an example of early binding. |
|
#6
| ||||
| ||||
| Re: early binding in a C++ Code: #include <iostream>
using namespace std;
class Base
{
public:
virtual int f() const { return 1; }
};
class Derived : public Base
{
public:
int f() const { return 2; }
};
int main()
{
Derived d;
Base* m1 = &n;
Base& m2 = n;
Base m3;
cout << "m1->f() = " << m1->f() << endl;
cout << "m2.f() = " << m2.f() << endl;
cout << "m3.f() = " << m3.f() << endl;
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "early binding in a C++" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Modern Warfare 2 key binding | Coty | Video Games | 4 | 26-03-2010 05:18 PM |
| How to break through ip plus mac binding? | Langward | Networking & Security | 5 | 24-03-2010 03:12 AM |
| How to use early binding in Visual Basic. NET | Radames | Software Development | 5 | 11-02-2010 05:53 AM |
| What is Data Binding? | Rum | Software Development | 5 | 29-01-2010 12:15 PM |
| Late Binding in C# | Katty | Software Development | 5 | 27-11-2009 10:09 AM |