Find the errors from the following codes and describe them? 1- #include<iostream
ID: 3553907 • Letter: F
Question
Find the errors from the following codes and describe them?
1-
#include<iostream>
using namespace std;
class B{
public:
int zip() { return x; }
private:
int x;
};
class D : public B{
public:
int zap() { return y; }
private:
int y;
};
int main(){
D *dptr;
B *bptr;
bptr = dptr;
dptr = bptr;
dptr = static_cast< D* >( bptr );
return 0;
}
2-
#include<iostream>
using namespace std;
class A { ~A (){} };
class B: public A { };
int main()
{
A *p, a_ob;
B *p2,b_ob;
p=&b_ob;
p2 = dynamic_cast<B * > (p);
if(!p2) cout<<"Cast fail";
return 0;
}
Explanation / Answer
1.invalid conversion from
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.