#include<iostream.h>
//main()
//{
class A
{
friend class B;
public:
void read();
};
class B
{
public :
int a,b;
};
void A::read()
{
cout<<"welcome";
}
main()
{
A x;
B y;
y.read();
}
In the above program......,
as B is a friend of A B can have access to all members,i
cant access y.read .
could you please tell me the reason and what would i code
to execute this program?
Answers were Sorted based on User's Feedback
Answer / manzoor
write a program to larger of two number by using friend
function in c++
| Is This Answer Correct ? | 5 Yes | 0 No |
Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and calculate its complexity T(n).
1 Answers Infosys, Qatar University,
solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)
program to find the magic square using array
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
3 Answers TCS, Vimukti Technologies, Wipro,
Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?
2 Answers ABC, Qatar University,
Given 1 to n distinct random number of which n+1th element was duplicated. How do find the duplicate element and explain the time complexity of the algorithm.
how to find out the maximum number out of the three inputs.
6 Answers ABC, Apple, C3I, HP, TCS,
Find the maximum product of three numbers in an array? Eg. 9,5,1,2,3 Max product= 9*5*3= 135 The array can hav negative numbers also..
An array of size 5X5 is given to us. The elements from 1 to 25 are to be inserted in the array, such that starting from a particular position for an element i, the next element i+1can be inserted only at the mentioned positions (u,v), and if these all positions are occupied then it returns giving a count of how many positions have been occupied in the array: (u,v) = (x+/-3 , y) (u,v) = (x , y+/-3) (u,v) = (x+/-2 , y+/-2). Example: if the starting element is 1 with the given positions (1,2), then next element 2 can be placed at any one of the positions marked with *. _ _ _ _ _ 1 _ _ _ * _ _ _ _ _ _ _ * _ _ * _ _ _ _
what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }
What will be the output- for(i=1;i<=3;i++) { printf("%d",i); continue; i++; }
How to swap two ASCII numbers?