C++ Programming - Objects and Classes - Discussion
Discussion Forum : Objects and Classes - General Questions (Q.No. 24)
24.
Which of the following statements is correct about the program given below?
class Bix
{
public:
static void MyFunction();
};
int main()
{
void(*ptr)() = &Bix::MyFunction;
return 0;
}
Discussion:
19 comments Page 2 of 2.
Dipak Dhondge said:
1 decade ago
Compiler errors mean the compiler could not translate the source code you provided into object code. It usually means you have a syntactic or semantic error in your own program that you have to resolve before your program exhibits the behavior you're intending it to have.
Linker errors mean the linker could not build an executable program from the object code you provided. It usually means your program does not properly interface with its own dependencies or with the outside world (e.g. External libraries).
Linker errors mean the linker could not build an executable program from the object code you provided. It usually means your program does not properly interface with its own dependencies or with the outside world (e.g. External libraries).
Ankit.w. said:
1 decade ago
Function in main should be like :
void (Bix::*ptr)()= &Bix::Myfunction;
void (Bix::*ptr)()= &Bix::Myfunction;
Vinay said:
1 decade ago
The linker error comes because the class is only declared and the definition is not there for the static member function. If we give a definition for member function then the linker error will be resolved by adding the following code.
void Bix::MyFunction()
{
std::cout << "I am a static function of Class Bix"
}
void Bix::MyFunction()
{
std::cout << "I am a static function of Class Bix"
}
Babbu said:
1 decade ago
What is linker error?
K SOWJANYA said:
1 decade ago
Can anybody explains clearly why it reports linking error?
Bhanu said:
1 decade ago
Linker error is coming because we have redefine static function outside the class.
void Bix::Myfunction(); // Will solve linker problem.
void Bix::Myfunction(); // Will solve linker problem.
Lenold said:
1 decade ago
Void data type should not return any value.
Java said:
1 decade ago
What is linker error ? because on being compiled this program shows no error and no output.
Likitha said:
1 decade ago
Can someone explain?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers