Answer the following statements true (T) or false (F)

1. A class is a type similar to a structure type that normally has member functions as well as member variables.
2. Consider the class and struct definitions below.
```
struct myStruct
{
int i;
double d;
};
class myClass
{
int i;
double d;
};
myStruct a;
a.i = 3;
myClass b;
b.i = 3;
```
True or False: All these statements will compile with no problem.
3. The concept of class is central to Object Oriented Programming.
4. A class type cannot be used in some ways that a built-in type can be used.
5. In defining a member function whose declaration is in a class, you use the dot operator to specify that the member function being defined belongs in the class, as
```
class foo
{
public:
// other members
void output( );
// other members
};

void foo.output( )
{
/* whatever */
}
```

1. True
We have treated the structure as a data members only aggregate, as C does, and we treat the class as having function members and data members.
2. False
The access for class defaults to private. When compiling this code one compiler warns: and another warns in addition that:
cpp 17: 'myClass::i' is not accessible in function main()
Another compiler warns in addition that all members of class myClass are private. The code b.i = 3; attempts to access a private member of myClass, and will cause the compiler to issue an error message.
3. True
The class concept supports OOP. Object oriented programming (OOP) is a powerful technique that divides problems by who is acting in a problem (actors are the class type objects) and what they are doing (these are the member functions.)
4. False
A class is a type just like an int or a double. You have variables or function parameters of class type. You can return a class object from a function. You can treat a class just like any other type.
5. False.
This is a mistake that students who have studied Java may make. Nevertheless, it occurs among all groups of students. C++ uses the scope resolution operator when we are specifying what class a member is from, and a dot operator to specify the calling object. The correct syntax for this function definition follows. Note carefully the use of the scope resolution operator, ::to specify that output is being defined in the scope of class foo.
```
void foo::output( )
{
/* whatever */
}
```

Computer Science & Information Technology

You might also like to view...

Programs that detect and respond effectively to unexpected user input are formally referred to as robust programs and informally as bulletproof programs.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

If you want to unlink a mask to move it independently of its layer, tap or click the ___ icon on the Layers panel.

A. mask B. link C. options bar D. layers

Computer Science & Information Technology