Question 76
What is the meaning of the following declaration? (Choose two.)
char **ptr;
char **ptr;
Question 77
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1[]= {"H" , "t" };
string s;
for (int i=0; i<2; i++) {
s = s1[i];
s.insert(1,"o");
cout << s;
}
return( 0 );
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1[]= {"H" , "t" };
string s;
for (int i=0; i<2; i++) {
s = s1[i];
s.insert(1,"o");
cout << s;
}
return( 0 );
}
Question 78
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class Test {
float i,j;
};
class Add {
public:
int x,y;
Add (int a=3, int b=3) { x=a; y=b; }
int result() { return x+y;}
};
int main () {
Test test;
Add * padd;
padd = &test;
cout << padd?>result();
return 0;
}
#include <iostream>
using namespace std;
class Test {
float i,j;
};
class Add {
public:
int x,y;
Add (int a=3, int b=3) { x=a; y=b; }
int result() { return x+y;}
};
int main () {
Test test;
Add * padd;
padd = &test;
cout << padd?>result();
return 0;
}
Question 79
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void fun(int*);
int main()
{
int i=2;
fun(&i);
cout<<i;
return 0;
}
void fun(int *i)
{
*i = *i**i;
}
#include <iostream>
using namespace std;
void fun(int*);
int main()
{
int i=2;
fun(&i);
cout<<i;
return 0;
}
void fun(int *i)
{
*i = *i**i;
}
Question 80
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
class First
{
string name;
public:
First() {
name = "Alan";
}
void setName(string n) {this?>name = n;}
void setName() {this?>name = "John";}
void Print(){
cout << name;
}
};
int main()
{
First ob1,*ob2;
ob2 = new First();
First *t;
t = &ob1;
t?>setName();
t?>Print();
t = ob2;
t?>setName("Steve");
ob2?>Print();
}
#include <iostream>
#include <string>
using namespace std;
class First
{
string name;
public:
First() {
name = "Alan";
}
void setName(string n) {this?>name = n;}
void setName() {this?>name = "John";}
void Print(){
cout << name;
}
};
int main()
{
First ob1,*ob2;
ob2 = new First();
First *t;
t = &ob1;
t?>setName();
t?>Print();
t = ob2;
t?>setName("Steve");
ob2?>Print();
}
