Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote