Write a program in c plus plus to sort a book list in library?
#include<iostream>
#include<string>
#include<vector>
struct book
{
std::string title;
std::string author;
// other members ...
};
int main()
{
std::vector<book> books;
books.push_back ( book {"Moby Dick", "Herman Melville"});
// ...
}
Parameterized constructor in c plus plus?
Every class requires at least one constructor, the copy constructor. It is implied if not declared. If no constructors are declared, a default constructor is also implied. Every class also requires a destructor, which is also implied if not declared.
The purpose of constructors is to construct the object (obviously) but by defining your own you can control how the object is constructed, and how member variables are initialised. By overloading constructors, you allow instances of your object to be constructed in several different ways.
The copy constructor's default implementation performs a member-wise copy (a shallow-copy) of all the class members. If your class includes pointers, you will invariably need to provide your own copy constructor to ensure that memory is deep-copied. That is, you'll want to copy the memory being pointed at, not the pointers themselves (otherwise all copies end up pointing to the same memory, which could spell disaster when one of those instances is destroyed).
The destructor allows you to tear-down your class in a controlled manner, including cleaning up any memory allocated to it. If your class includes pointers to allocated memory, you must remember to delete those pointers during destruction. The destructor is your last-chance to do so before the memory "leaks". The implied destructor will not do this for you -- you must implement one yourself.
class foo
{
public:
foo(){} // Default constructor.
foo(const foo & f){} // Copy constructor.
~foo(){} // Destructor.
};
Swap function in c plus language?
#include<iostream>
void swap(int* x, int* y)
{
int tmp = *x; *x=*y; *y=tmp;
}
int main()
{
int a=2, b=4;
std::cout<<"a="<<a<<", b="<<b<<std::endl;
swap(&a, &b);
std::cout<<"a="<<a<<", b="<<b<<std::endl;
}
How do you write the concatenate the strings using pointer?
char* strcat (char* destination, const char* source) {
char* return_value = destination; // temp destination for return
while (*(destination++) != '\0'); // find end of initial destination
while ((*(destination++) = *(source++)) != '\0'); // copy source to end of destination
return return_value; // return original value of destination
}
Do you use virtual functions in Java?
Every method in java that isn't a class (static) method is automatically "virtual." If you want to disable virtual overrides, make the method "final" in the base class.
How is a c plus plus program stored in the memory?
C++ programs are not stored in memory (RAM) they are stored on mass storage devices (usually disk drives). When compiled, they produce machine code programs which contain machine instructions and their operands. These are also stored on mass storage devices, but when loaded into memory the machine instructions are executed by the CPU.
What is the difference between struct in c and c plus plus?
In C, a struct is simply a type that can hold several sub-objects.
In C++, struct is almost the same as "class". It can have member functions, parent structs and classes, etc. The only difference between struct and class is that the members of class are by default private, while the members of struct are by default public. Thus, a standard C struct is also a good C++ struct - simply one that has no member functions and no parents.
How can you explain reverse polish notation in simple words?
Reverse Polish Notation (RPN) is a system where expressions are evaluated from left to right, with no precedence, with operators stated following the operands. A typical RPN expression might be ab+c*, which in infix means (a+b)*c. (Infix is our "standard" system which we use when writing programs) Note that the infix expression required parenthesis to override operator precedence, but the RPN expression did not. If you said in infix a+b*c, the RPN equivalent would be abc*+. The value of RPN is that it is easy to build a stack machine that processes the expression. Each time you encounter an operand, you push it on the stack. Each time you encounter an operator, you process it, replacing the top two elements of the stack with the result (for binary operators), or replacing the top element of the stack with the result (for unary operators). RPN is often used in compiler design.
Can somebody give me the program to find simple interest using friend function in c plus plus?
Here is an example program:
class obj{
public:
float p,n,r,si;
friend void calc( obj temp);
};
void calc( obj temp){
si = (p*n*r)/100;
}
The initialization and function calling is essential.
What is a template class in c plus plus?
Templates allow us to reduce the need to write duplicate code ourselves and force the compiler to duplicate the code for us. This saves a great deal of time (and money) and greatly reduces code maintenance because there's only one version of the implementation to modify. This greatly reduces the chances of us making a mistake because the compiler will propagate all the changes for us. Moreover, we don't need to second-guess what data types we might need to cater for in the future because the compiler will generate specific versions on an as-required basis, according to the types we actually use -- including those we haven't yet designed!
You've probably been taught that code duplication is a bad thing -- and you'd be right -- but it is also a necessary evil. The difference with templates is that rather than placing the onus upon the programmer to ensure the code duplication is consistent, the onus is placed entirely upon the compiler.
So when do we need code duplication? We need it whenever the implementation of a function or a class differs only in the type of data they operate upon. That is, one class or function definition that caters for any data type, rather than creating many separate classes or functions for each data type. If the implementations are exactly the same in every way, then duplicate code is inevitable. It's simply a matter of whether we write it ourselves and accept all the pitfalls that come with that, or we let the compiler do all the donkey work for us. The latter is always the preferred option every time.
Consider the following simple example:
int max(int a, int b){ return(a
double max(double a, double& b){ return(a
foo& max(foo& a, foo& b){ return(a
As you can see, all three functions have exactly the same implementations, they only differ in the type of data they operate upon. This is where templates come in. If we replace the data type with a template parameter then we need only define the function once:
template
T max(T a, T b){ return(a
Note that T is a standard token for a template parameter. If we needed more than one data type in the same function or class then we'd use tokens T1, T2, etc. The compiler will replace these tokens with the actual data type we supply at compile time.
Now when we call max(), the compiler will generate the appropriate overload for us at compile time, provided both arguments are covariant (are of the same intrinsic type). Thus the following are acceptable calls to max():
int x=42;
int y=2112;
int z=max(x,y); // z==2112
std::string s1("hello");
std::string s2("world");
std::string s3=max(s1,s2); // s3=="world"
It should be noted that since templates are incomplete types, the implementation must be made visible to the compiler BEFORE encountering any usage of the template for the first time. Thus you must either define the function within the declaration, or outside of the declaration but within the same file or #include the file containing the definition immediately after the declaration. If defining outside of the declaration, remember to also include the template:
// declaration...
template
T max(T a, T b);
// definition...
template
T max(T a, T b) { return(a
The same principal applies to classes where one or more data members employ template parameters. However, you must include the template keyword in every member method defined outside of the class, including the class constructors, as per the following example:
template
class foo
{
public:
foo(const T data):m_data(data){}
foo(const foo&); // defined externally...
private:
T m_data;
};
template
foo
Whenever you instantiate any objects from a template class, you must also provide the data type(s) so the compiler knows how to generate the complete class definition. For example:
foo
foo
Now that you have a basic understanding of templates, you should find working with the STL containers (including std::list and std::vector) that much easier.
A template is an incomplete type. Template functions can be likened to overloaded functions where the implementation is exactly the same, the only difference being the type of argument or arguments passed to the function. For instance, when determining the larger of two objects of the same type, the implementations would be the same regardless of the type, like so:
int& max(int& x, int& y){ return(y float& max(float& x, float& y){return(y Since this function can be applied to any object that supports the less-than operator, writing all the overloads by hand places a heavy burden upon the programmer. Every time the programmer creates a new object that supports the less-than operator, they would have to write a new overload to cater for it. C++ templates make it much simpler by allowing the programmer to define the function just once, using template parameters instead of formal arguments, like so: template T& max(T& x, T& y){ return(y When you call the max function, the compiler automatically generates the appropriate overload for you (unless one was already generated by an earlier call with the same type). Function templates can also be used within classes (template methods). In this case, the compiler generates separate overloads for each method within the class according to the types passed to those methods. However, if the class contains a template data member, the compiler generates separate classes for each type. This is known as a template class. The following code demonstrates all these concepts: #include // template function: template T& max(T& x, T& y){ return( y // template method: struct A { template T& max(T& x, T& y){ return( y }; // template class: template struct B { T data; const bool operator< (const B& b){ return( this->data }; template std::ostream& operator<< (std::ostream& os, const B int main() { int i1=24, i2=42; double d1=4.2, d2=2.4; A a; B B B B std::cout<<"Calling template function:\n"< std::cout<<"The maximum of "< std::cout<<"The maximum of "< std::cout< std::cout<<"Calling template method of class A:\n"< std::cout<<"The maximum of "< std::cout<<"The maximum of "< std::cout< std::cout<<"Calling template function with template class B types:\n"< std::cout<<"The maximum of "< std::cout<<"The maximum of "< std::cout< std::cout<<"Calling template method of class A with template class B types:\n"< std::cout<<"The maximum of "< std::cout<<"The maximum of "< std::cout< } Output Calling template function: The maximum of 24 and 42 is 42 The maximum of 4.2 and 2.4 is 4.2 Calling template method of class A: The maximum of 24 and 42 is 42 The maximum of 4.2 and 2.4 is 4.2 Calling template function with template class B types: The maximum of 24 and 42 is 42 The maximum of 4.2 and 2.4 is 4.2 Calling template method of class A with template class B types: The maximum of 24 and 42 is 42 The maximum of 4.2 and 2.4 is 4.2 Note that there is only one class A type, and that it contains two overloads of the max function. However there are two class B types (one for int, the other for double). Thus although you could assign bi1 to bi2 because they are the same type, you cannot assign bi1 to bd1 because they are different types.
Can you delete Microsoft visual c plus?
To delete Microsoft Visual C/C++, like any other Windows program, simply uninstall it using Control Panel / Add-Remove Programs. For additional information, consult the readme that came with the original program.
What is the program structure of C language and C plus plus?
There is no single structure to a C++ program. C++ is multi-paradigm and allows programmers to use any combination of C-style programming, object-oriented programming and template metaprogramming using a mixture of primitive built-in types, standard library types and user-defined types.
C plus plus Program that will convert from decimal to octal?
The following code will convert any number in any base to any other base, from binary to hexadecimal, and everything inbetween.
#include<iostream>
#include<string>
#include<sstream>
typedef unsigned long long ull;
typedef unsigned long ul;
const std::string symbols="0123456789abcdef";
std::string inputvalue(ul base)
{
using namespace std;
string value;
while(1)
{
cout<<"Enter a positive value : ";
string s;
getline(cin,s);
if(s.size())
{
for(string::iterator i=s.begin();i!=s.end();++i)
if(*i>='A' && *i<='Z')
*i+=32;
string actual = symbols.substr(0,base);
if(s.find_first_not_of(actual)!=string::npos)
{
cout<<"The value you entered is invalid for the base.\n"
<<"Please enter another value.\n"<<endl;
continue;
}
value=s;
break;
}
}
return(value);
}
ul inputbase(std::string prompt)
{
using namespace std;
ul result=0, min=2, max=16;
while(1)
{
cout<<prompt.c_str()<<" ["<<min<<".."<<max<<"] : ";
string s;
getline(cin,s);
if(s.size())
result=stoul(s,0,10);
if(result<min result>max)
cout<<"The base must be in the range "
<<min<<".."<<max<<"\n"
<<"Please enter another base.\n"<<endl;
else
break;
}
return(result);
}
ull base2dec(std::string value,ul base)
{
ull col=1, num=0;
for(std::string::reverse_iterator i=value.rbegin(); i!=value.rend(); ++i)
{
num+=symbols.find(*i,0)*col;
col*=base;
}
return(num);
}
std::string dec2base(ull dec,ul base)
{
using namespace std;
int len=1;
ull tmp=dec;
while(tmp/=base)
++len;
string value("0",len);
while(dec)
{
value[--len]=symbols[dec%base];
dec/=base;
}
return(value);
}
int main()
{
using namespace std;
ul base=inputbase("Enter the base of the value");
string value=inputvalue(base);
ul newbase=inputbase("Enter the base to convert to");
value=dec2base(base2dec(value,base),newbase);
cout<<"New value:\t"<<value.c_str()<<endl;
return(0);
}
What is a dosh header file in c?
Not sure what dosh is but dos.h was used by Turbo C/C++ to handle DOS interrupts way back in the early 90s. DOS has largely been consigned to the history books now that Windows is an OS in its own right. Until 1995 it ran on top of DOS, the actual OS, but no-one in their right mind would consider running DOS programs in Windows in this day and age. Console applications are not DOS programs, they are fully-fledged Windows programs but without a fancy GUI.
What is cin in c plus plus programming language?
We don't have to do anything fancy to implement this, we can simply extract the character sequence directly into a standard string object. By default, all leading whitespace characters (space, tab and newline) are ignored and extraction ends when the next whitespace or newline character is encountered in the character sequence.
#include<iostream>
#include<string>
int main () {
std::string s {};
std::cout << "Enter some text:\n";
std::cin >> s;
std::cout << "The first word input was:\n";
std::cout << s << std::endl;
}
Output:
Enter some text:
one two three
The first word input was:
one
What is the C plus plus program for regula falsi method?
#include
#include
#include
/* define prototype for USER-SUPPLIED function f(x) */
double ffunction(double x);
/* EXAMPLE for "ffunction" */
double ffunction(double x)
{
return (x * sin(x) - 1);
}
/* -------------------------------------------------------- */
/* Main program for algorithm 2.3 */
void main()
{
double Delta = 1E-6; /* Closeness for consecutive iterates */
double Epsilon = 1E-6; /* Tolerance for the size of f(C) */
int Max = 199; /* Maximum number of iterations */
int Satisfied = 0; /* Condition for loop termination */
double A, B; /* INPUT endpoints of the interval [A,B] */
double YA, YB; /* Function values at the interval-borders */
int K; /* Loop Counter */
double C, YC; /* new iterate and function value there */
double DX; /* change in iterate */
printf("-----------------------------------------------------\n");
printf("Please enter endpoints A and B of the interval [A,B]\n");
printf("EXAMPLE : A = 0 and B = 2. Type: 0 2 \n");
scanf("%lf %lf", &A, &B);
printf("The interval ranges from %lf to %lf\n", A,B);
YA = ffunction(A); /* compute function values */
YB = ffunction(B);
/* Check to see if YA and YB have same SIGN */
if( ( (YA >= 0) && (YB >=0) ) ( (YA < 0) && (YB < 0) ) ) {
printf("The values ffunction(A) and ffunction(B)\n");
printf("do not differ in sign.\n");
exit(0); /* exit program */
}
for(K = 1; K <= Max ; K++) {
if(Satisfied 0) { /* first 'if' */
Satisfied = 1; /* Exact root is found */
}
else if( ( (YB >= 0) && (YC >=0) ) ( (YB < 0) && (YC < 0) ) ) {
B = C; /* Squeeze from the right */
YB = YC;
}
else {
A = C; /* Squeeze from the left */
YA = YC;
}
if( (fabs(DX) < Delta) && (fabs(YC) < Epsilon) ) Satisfied = 1;
} /* end of 'for'-loop */
printf("----------------------------------------------\n");
printf("The number of performed iterations is : %d\n",K - 1);
printf("----------------------------------------------\n");
printf("The computed root of f(x) = 0 is : %lf \n",C);
printf("----------------------------------------------\n");
printf("Consecutive iterates differ by %lf\n", DX);
printf("----------------------------------------------\n");
printf("The value of the function f(C) is %lf\n",YC);
} /* End of main program */
How do you call multiple constructors with single object?
You can have any number of constructors for a class. All we need to do is implement constructor overloading.
Ex: let us say we want to create multiple constructor for a class Test
Public class Test {
Public Test() {
//code
}
Public Test(int vals) {
//code
}
Public Test(String val) {
//code
}
}
What are the advantages of using string in c plus plus?
I assume you mean std::string rather than strings in general. Programs that need to convey any information to the user will usually require many strings, and when retreiving input from the user, a string (in conjunction with a string stream) are the best way of checking that data before processing it. The std::string (and its wide-character counterpart, std::wstring) needn't be used for all strings, of course, but they are much easier to work with when strings need additional processing, such as when concatenating strings, or searching within strings. And if you need more functionality than is provided by std::string alone, you can always derive a new string object from std::string and embelish it as required. Of course, if you require less functionality than is provided by std::string then you have the option of creating your own lightweight string class from scratch. However, for most applications, std::string is lightweight enough, and if you use std::string at all, then there's little point in writing your own string class. Aside from re-inventing the wheel (one of the reasons the STL exists), it's only going to increase your code size. However, for new programmers, it can be an interesting excercise creating your own string class, if only to show how std::string works and why re-inventing wheels is rarely a good thing.
Why did c plus plus become more popular inspite of so many object oriented languages available?
All languages are interesting to some degree or another. Programming languages in particular allow us humans to communicate with and ultimately control computers, bending them to our will. However, some languages are better than others for certain tasks. C++ is a general purpose, cross-platform, high-level language that can produce highly-efficient machine code (the native language of the computer). What makes it interesting is subjective -- each programmer will have their own likes and dislikes -- but ultimately the language gives a high-degree of control over the hardware, exploiting specific features of the architecture.
The same kind of thing can be achieved using Assembly Language (a low-level language), and in many ways would be regarded as a more interesting language than C++. But it is extremely difficult to work with. Even if you have access to a vast library of pre-written routines, you still require intimate knowledge of the underlying hardware and must write programs in minute detail. C++ can achieve similar results, but the abstraction between the hardware and the code you write is such that you needn't concern yourself with the hardware quite so much. That is, a single instruction in C++ can easily generate dozens of assembly instructions.
C++ becomes more interesting when compared to languages that don;t provide the level of control, such as Java. This is an entirely object-oriented programming language, with a higher-degree of abstraction (with little or no interaction with the underlying architecture). Rather than producing machine code, Java produces byte code which can be run on any platform that supports the Java Virtual Machine. As such, it is more portable as programs need only be compiled once to run on any platform whereas C++ code must be compiled separately for each platform, and must include code to filter out code that is irrelevant to the current platform. However, since Java programs must run in a virtual machine, they are very much slower than equivalent C++ programs.
C++ is also more interesting in that you aren't restricted to using object-oriented programming principals. You can choose to mix C++ code with C-style code (which is a structured language) and also raw assembly routines, thus making it far more flexible than Java, which is entirely object-oriented.
Although there's little you can't do in C++, that doesn't make it the best language in every situation. For instance, if you have a deadline to meet, C++ might be too complex a language to meet that deadline, thus forcing you to use a more abstract language designed specifically for rapid application development (RAD). For instance, it's often useful to model algorithms and design concepts using a RAD before committing yourself to a more lengthy software development in C++. The feedback from the RAD can, in fact, reduce the overall development cycle as the models can often be incorporated into the final design with only minimal or trivial modification.
However, C++ comes into its own when high-performance is the main criteria, and raw Assembly Language would be far too costly to implement in a reasonable time-frame. Modern compilers can optimise the machine code in much the same way an Assembly Language programmer exploits hardware features to produce highly-efficient code, but there's often room for further improvement. However, C++ is flexible enough to allow the programmer to make these adjustments by hand. And, for me, that's where things can get really interesting.
What does c plus plus use call by value or call by reference?
When we call a function in C++ by passing the values as arguments, it is called call by value.
e.g
#include<iostream.h>
#include<conio.h>
int add(int,int);
int main()
{
int a,b,c;
cout<<"Enter numbers.";
cin>>a>>b;
c=add(a,b);
cout<<"Sum : "<<c;
return 0;
}
int add(int a,int b)
{
int c;
c=a+b;
return c;
}
What are the drawbacks of function overloading?
None whatsoever. There is always the chance you will end up creating overloaded functions that are never used, but your compiler should be able to eliminate these for you (unreachable code). Otherwise there is no harm in having them in your source code, especially if the code is intended to be re-usable. For those that are functionally the same, the only difference being the type of parameter, template functions are a far better solution to overloading for every conceivable type. The compiler will generate the overloads for you, on an as-required basis, and you only have the one function to maintain.
What is the problem of an array based queue?
A queue is a first-in, first-out (FIFO) structure. This means insertions occur at the end of the data sequence while extractions occur at the beginning of the sequence. Array-based queues are problematic for two reasons.
Inserting at the end of a sequence is fine when there are unused elements available (which you must keep track of), but when the queue is full the array must be resized in order to free up more unused elements. If there is insufficient memory to expand into the entire array must be reallocated to new memory which means the entire array must be copied. Copying arrays is an expensive operation as every element must be copied individually. An array of pointers (or resource handles with move semantics) rather than an array of objects would improve efficiency but for the duration of the copy process you will be consuming more than twice as much memory; one block for the original queue and another larger block for the new allocation.
However, the biggest problem is what to do when elements are extracted from the front. This will mean you have an unused element at the beginning of the array and the only way to eliminate it is by shunting all elements forward by one and that means copying them (again, pointers or resource handles would be more efficient). A better approach is to use a circular array such that you keep track of the unused elements at both the beginning and end of the sequence.
What are the various data types in C plus plus?
Data types specify how data is interpreted. All data in a binary computer is stored as a sequence of bits (binary digits), thus all data is represented by numeric values. The data type associated with that data determines how many bits the data occupies and how that data should be interpreted. For instance, an unsigned char data type occupies 8 bits (1 byte) which translate to a numeric value in the range 0 to 255. These values map to ASCII character codes in the current code page, thus if you were to output a char data type it would print the character associated with the character code rather than the numeric value of the code. Unicode character codes use 16 bits (2 bytes) to represent each character and are therefore unsigned short types, also known as wchar_t types.
The primitive data types include int, short and char, which are all integral data types used to store integers (whole numbers). Each may be further qualified with the signed or unsigned keywords, thus a signed char will represent values in the range -128 to +127.
Strings of characters are represented as an array of char types, typically terminated by a null character which has the value 0. Arrays are simply sequence containers containing one or more data elements of the same type. Since the length of each element is the same, it is trivial to locate any element within the array given the element's index where the first element can be found at index 0. Thus an array of n elements will have indices in the range 0 to n-1. Knowing the size of each element (as determined by its type) means that element x can be found at the memory address x*sizeof(element) bytes from the start of the array, using nothing more than simple pointer arithmetic. However, when you declare an array, the subscript operator can be used to specify the index of the element you wish to examine, while C++ does the pointer arithmetic in the background.
More complex data types can be declared using class or struct keywords. The declaration of these types determines how they are mapped in memory and ultimately how they are interpreted. Primitive data types act as the building blocks for these complex data types, but more complex data types can be composed from any combination of primitive and pre-existing complex data types to produce ever more highly complex data types.
Instances of a type are known as variables or constants, depending on whether the value of the instance can be changed or not. If the type is a complex data type, such as a class or struct, the instance is known as an object, which can also be variable or constant. Many new users regard classes and objects as being the same thing, however a class is the definition of a type while an object is an instance of the type, in the same way that a char is a type while a char variable is an instance of the type.
How do you write a c function to swap two variables without using a temporary variable?
You can swap values a and b without a temporary as follows:
a=a^b
b=a^b
a=a^b
(^ is the bitwise XOR operator)
To show how this works, let's consider the values a=180 and b=204. In binary, 180 is 10110100 while 204 is 11001100. Thus:
a = 10110100
b = 11001100
a^b means that we look at the corresponding bits in each input value and output a 1 if one and only one of the two input bits is set. Thus the output (o) is:
a = 10110100
b = 11001100
o = 01111000
In the expression a=a^b, the output of a^b is assigned to a, thus the values of a and b now look like this:
a = 01111000
b = 11001100
We then repeat the operation, a^b, this time assigning the output to b:
a = 01111000
b = 11001100
o = 10110100
So now we have:
a = 01111000
b = 10110100
We repeat the operation one more time, assigning the output value to a:
a = 01111000
b = 10110100
0 = 11001100
So now we have:
a = 11001100
b = 10110100
The two values have now been swapped.
To write this in C, we can use shorthand expressions using the compound XOR-ASSIGN operator (^=):
a^=b
b^=a
a^=b
These individual expressions can then be combined into a single expression:
a^=b^=a^=b
Finally, to use this expression in a C function, we need to pass a and b by reference (using pointer variables):
void swap (int* a, int* b) {
(*a)^=(*b)^=(*a)^=(*b);
}
Note that a and b must be of an integral type (char, short, long, int, unsigned, etc). The example above only works on type int. If we wish to swap other types, or more complex types, we must treat those values as if they were an integral type. One way to achieve this is to treat those types as if they were an array of type char, supplying the length of the arrays through a separate argument:
void swap (char* a, char* b, size_t size) {
for (int i=0; i<size; ++i) {
a[i]^=b[i]^=a[i]^=b[i];
}
}
For example, to swap two doubles, we can use the following call:
int main (void) {
double a, b;
a = 3.14;
b = 1.1;
swap ((char*) &a, (char*) &b, sizeof (double));
assert (a==1.1);
assert (b==3.14);
return 0;
}
Note that a and b must of the same type.
What is a pure virtual member function in c plus plus?
Functions in C++ are separate procedures or subroutines within a program, that can be called as often as required and which can return values back to their callers. That is, when you make a function call, execution passes to the function and then returns to the caller.
Functions that are class members are also known as member functions, member methods, or simply methods. These work exactly the same as external functions except they are scoped to the class and have access to private members of the class.