Posted by
splakhani
at
2:20 PM
Posted by
splakhani
at
6:42 PM
Posted by
splakhani
at
6:42 PM
Posted by
splakhani
at
6:40 PM
Posted by
splakhani
at
6:36 PM
Posted by
splakhani
at
7:01 PM
Posted by
splakhani
at
10:44 AM
Posted by
splakhani
at
6:37 PM
Posted by
splakhani
at
6:29 PM
1) Which is the parameter that is added to every non-static member function when it is called?
---------------------------------------------------------------------------------------
2)
class base
{
public:
int bval;
base(){ bval=0;}
};
class deri:public base
{
public:
int dval;
deri(){ dval=1;}
};
void SomeFunc(base *arr,int size)
{
for(int i=0; i <>bval;
cout << endl; } int main() { base BaseArr[5]; SomeFunc(BaseArr,5); deri DeriArr[5]; SomeFunc(DeriArr,5); }
---------------------------------------------------------------------------------------
3)
class base { public: void baseFun(){ cout << "from base" <<>baseFun();
}
int main()
{
base baseObject;
SomeFunc(&baseObject);
Deri deriObject;
SomeFunc(&deriObject);
}
---------------------------------------------------------------------------------------
4)
class base
{
public:
virtual void baseFun(){ cout << "from base" <<>baseFun();
}
int main()
{
base baseObject;
SomeFunc(&baseObject);
Deri deriObject;
SomeFunc(&deriObject);
}
---------------------------------------------------------------------------------------
5)
class some
{
public:
~some()
{
cout << "some's destructor" << endl; } }; void main() { some s; s.~some(); } ---------------------------------------------------------------------------------------
6) #include class fig2d { int dim1; int dim2; public: fig2d() { dim1=5; dim2=6;} virtual void operator<<(ostream & rhs); }; void fig2d::operator<<(ostream &rhs) { rhs <<>dim1 <<" "<
}
*/
void main()
{
fig2d obj1;
// fig3d obj2;
obj1 << cout; // obj2 << cout; }
return true;
else
return false;
}
int main()
{
complex c1;
cout << c1;
}
Class complex
{
double re;
double im;
public:
complex() : re(0),im(0) {}
complex(double n) { re=n,im=n;};
complex(int m,int n) { re=m,im=n;}
void print() { cout << re; cout << im;}
};
void main()
{
complex c3;
double i=5;
c3 = i;
c3.print();
}
00000
2. 01010
3. from base
from base
4. from base
from Derived
5. some's destructor
some's destructor
6. 5 6
7. Runtime Error: Stack Overflow
8. Garbage value
9. 5,5
Posted by
splakhani
at
5:01 PM
Question :: Read below code and answer the following questions. LINE Contains 50 char * b, q, *r; 200 b=getbuf(); 201 q = *b; 212 r= anotherfunction(b); 213-300 /* we want to use ‘q’ and ‘r’ here*/ 2000 char * getbuf() 2001 { 2002 char buff[8]; 2003-2050 /* unspecified, buff defined here *./ 2051 return (char *) buff; 2052 }
1. What will be in variable ‘q’ after line 201 is executed? Under what conditions might this not be so?
Answer:
2. Is there an alternative, but equivalent, way to write line 2000? If so, what is it?
Answer:
3. Is getbuf() a reasonable function?
Answer:
4. Will getbuf() execute at all?
Answer:
5. Please comment on line 2051.
Answer:
6. Is getbuf() good practice, and why?
Answer:
7. What line not given should be provided for compilation?
Answer :
Posted by
splakhani
at
4:50 PM
Posted by
splakhani
at
7:13 PM
Posted by
splakhani
at
7:02 PM