answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Which section title requires an operators signature to verify the operator has read and understands the SOP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Which operator is called ternary operator?

A ternary operator is an operator that requires three operands, as opposed to a binary operator that requires two operands and a unary operator that requires just one operand. C++ has just one ternary operator, the conditional ternary operator: <boolean expression> ? <expression #1> : <expression #2>; If the boolean expression evaluates true, the first expression is evaluated, otherwise the second expression is evaluated. A typical usage of this operator is to return the larger (or smaller) of two values of type T: template<typename T> T max (T a, T b) {return a<b ? b : a}; template<typename T> T min (T a, T b) {return a<b ? a : b}; These are really nothing more than notational shorthand for the following: template<typename T> T max (T a, T b) {if (a<b) return b; else return a; }; template<typename T> T min (T a, T b) {if (a<b) return a; else return b;}; However, because ternary expressions are evaluated, the return value of the expression can be used in more complex expressions: int a=42, b=0; // ... int c = ((a>b ? a : b) = 1); In the above expression, whichever is the larger of a and b will be assigned the value 1 which will also be assigned to c. Thus a and c become 1 while b remains 0.


Define unary operator explain different unary operators used in c language?

A unary operator is one that requires only one operand. The unary operators are the prefix and postfix increment and decrement, positive and negative, logical and bitwise negation, and address and indirection operators, plus the words alignof, typeof, and sizeof.The first two operators are increment "++", and decrement "--". Its position before or after the variable determines prefix or postfix. Incrementing increases the stored value by 1, and decrementing decreases the stored value by 1. If it is to the left of the variable, the operation occurs before the variable is used; if it is to the right, it occurs after the variable is used.The positive operator "+" simply asserts the current value, and exists as acomplementto the negation operator "-". The negation operator returns the number with the opposing sign. If x is 5, then -x is -5, and if x is -5, then -x is 5.The logical negation "!" and bitwise negation "~" operators perform actions on individual bits. C considers zero to be false, and all other values to be true. Using logical negation, it returns true if the value is zero, or false for any other value. The bitwise negation changes all 1 bits to 0 bits, and 0 bits to 1 bits. For an unsigned byte, ~0 becomes 255, and ~255 becomes 0. For signed variables, ~0 would become -1, and ~-1 would become 0. This is because of the two's complement method of signed numbers.Address "&" and indirection "*" operators take the address or value of the operand. The address operator allows a variable to be passed by reference; modifying the reference will modify the original value. Using the indirection operator treats a variable as a memory address, which allows the programmer to access a specific spot in memory.Alignof, sizeof, and typeof are all used to determine the alignment, size, and type of objects dynamically. This is necessary when trying to determine how data is laid out when there may be differences in memory accesses across platforms (e.g. when reading a ZIP file's directory contents).


Which operand should be passed in the binary overloaded operator function as a second operand?

The right-hand operand; the r-value of the operator. Unary operators have one operand while tertiary operators have three operands. All binary operators have two operands, the l-value and the r-value. The l-value is the operand to the left of the operator while the r-value is the operand to the right of the operator. Thus, in the expression x + y, x is the l-value while y is the r-value. When overloading binary operators in a class, you need only specify the r-value. The l-value is the instance of the class to which the operator applies and therefore does not need to be specified. For instance: class MyClass { public: MyClass(int data=0):m_data(data){} // default constructor int operator+ (const int rhs) const {return(m_data+rhs);} private: int m_data; }; While this allows you to return the sum of your class instance and an integer, it does not allow you to return the sum of an integer and an instance of your class. For example: MyClass obj(5); int x = 10; int y = obj + x; // OK! y is 15. int z = x + obj; // Compiler error! No operator exists that accepts an r-value of type MyClass. To fix this error and allow for two-way addition, you must declare a binary operator overload outside of the class. You cannot do it inside the class because the l-value is an int, not an instance of MyClass. The external overload requires two parameters, the l-value and the r-value of the operator: int operator+(const int lhs,const MyClass& rhs) {return(rhs+lhs);} Note that the implementation simply reverses the operands. This is functionally equivalent to making the following explicit call: return(rhs.operator+(lhs)); Note also that since MyClass::operator+ is a public operator of MyClass, this overload does not need to be declared a friend of MyClass (a common misconception). However, the overload must be declared in the same file where the class is declared since it is only of relevance to MyClass but should be made available wherever MyClass is accessible.


How to overloade operater in c plus plus?

The assignment operator overload is a typical example of operator overloading. Every class of object has an assignment operator by default, which simply assigns the value of the members of an existing class to the members of another existing class. The two classes may even be the same class. However, the default implementation is not suitable for classes that contain pointers to memory that cannot be shared with other classes. Assigning the value of one pointer to another simply copies the pointer's value (a shallow copy) but not what it points at (a deep copy). Thus the assignment operator must be overloaded to perform a deep-copy, as per the following example: struct X { // destructor ~X(){ delete( m_pointer ); } // default constructor X(): m_pointer( new int(100) ){} // copy constructor X( const X& x): m_pointer( x.m_pointer ? new int( *x.m_pointer) : NULL ) {} // assignment operator overload X& operator= ( const X& x ); int* m_pointer; }; X& X::operator= ( const X& x ) { if( this != &x ) // test for self-reference {delete( m_pointer );m_pointer = x.m_pointer ? new int(*x.m_pointer) : NULL;} return( *this ); } In the above example, the assignment operator overload first checks to ensure that the incoming object is not a self-reference. If it is not, then we release the current allocation and create a new allocation, copying the incoming object's memory by value. If we had not checked for a self-reference, then we could easily end up deleting the very memory we wished to copy, such as in the following example: X x; X* y = &x; x = *y; // self-assignment In the above example, x and *y are obviously references to the same object, but it may not be quite so obvious if the assignment occurred elsewhere in our code. Therefore the object's assignment operator overload must cater for this eventuality and veto the assignment -- thus leaving the original object unchanged. The assignment operator can also be overloaded in order to prevent assignment. You would do this if the object were intended to act as a singleton, for instance. In this case we simply need to declare the operator as private to the class but do not need to provide any implementation. Alternatively, we can simply return a reference to the current instance: X& operator= ( const X& x ) { return( *this ); } No other operator has a default implementation when applied to classes, therefore if we want to make use of other operators upon our classes, such as +, ++ or +=, then we must overload them in the class declaration. Again, each overload must test for self-references and act accordingly. However, while there's nothing to prevent you from providing a completely unique implementation of these operators, common sense dictates that all such implementations must be intuitive and predictable. While it may be fun to implement the plus operator as a minus operation, it has no practical value in the real world -- it is neither intuitive nor predictable. The stream insertion (<<) and extraction (>>) operators are another typical example of operator overloading. These cannot be implemented within the class itself because the l-value of these operators must be a stream, while internal class operator overloads use the current instance of the class as the l-value. Therefore these operators must be implemented outside of the class. Many programmers implement these "external" operators as friend functions. While some do have valid reasons for doing so, if the public class interface provides everything required of these operators then there is no need to declare the operator as a friend function. Although some programmers continually claim friendship undermines encapsulation this is not the case at all. Friends simply extend the class interface, nothing more. However, if the underlying class implementation is altered, all friend functions may need to be updated to cater for these changes -- which increases the maintenance cost. Therefore, if operator overloads can be implemented with friend access, then your class becomes that much easier to maintain. Here's a typical example of an external operator implemented as a friend function: struc X { friend ostream& operator<<( const X& x ); private: int m_data; }; ostream& operator<<( ostream& os, const X& x ) { os << x.m_data; return( os ); } Now here's the same operator overload implemented without a friend function: struc X { int GetData() const { return( m_data ); } private: int m_data; }; ostream& operator<<( ostream& os, const X& x ) { os << x.GetData(); return( os ); } While there's clearly the need for an extra function call, that call is completely eliminated by virtue of the fact X::GetData() will be inline expanded by the compiler. Thus the latter will not affect performance in any way. However, the main advantage of the non-friend function comes when you later decide to alter the implementation of the class: struc X { int GetData() const { return(( int ) m_data ); } private: double m_data; }; Here we've changed the member variable to a double, but the GetData() accessor method still returns an int. The accessor is therefore an abstraction, thus the insertion operator overload is left unaffected by the internal change to the class. However, had we made this same change in the earlier example employing the friend function, there is no abstraction and the extraction operator will insert a double into the output stream. If this were undesirable then we'd have to alter the friend function as well. Not only have we increased the maintenance, we've completely undermined the abstraction of our class. Note that we have not undermined the encapsulation (as some would claim), only the abstraction has been undermined. Thus if you want to retain the abstraction, do not use a friend function. Friend functions should only be used when abstraction is not an issue, and the function genuinely requires access to the private members of the class.


Which Logic Function requires both inputs to be 1 in order to output a1?

This would be the "AND" operator. 1 AND 1 = 1.1 AND 0 = 0. 0 AND 0 = 1

Related questions

What is a One Off Production?

Where a single item is made on its own by one operator which takes time and requires highly skilled,experienced operators


Which of the following requires powered industrial truck operator recertification?

Forklift operator


What qualification would one need to be an operator's assistant in surgery?

The qualification required to be a operators assistant in surgery requires a degree for nursing and medical care, a doctors degree would also prove very helpful in application to the position.


Who would rescue tourists if they were ill on antarctica?

Tour operators usually bring medical experts with them on cruises. As required, the tour operator would call on whatever search and rescue resources are closest in the event a tourist requires a med-evac back to civilization.


What job requires crane operator training?

In order to become a crane operator you will need to get crane operator training. This will enable you to operate a crane for a variety of construction jobs.


Which operator is called ternary operator?

A ternary operator is an operator that requires three operands, as opposed to a binary operator that requires two operands and a unary operator that requires just one operand. C++ has just one ternary operator, the conditional ternary operator: <boolean expression> ? <expression #1> : <expression #2>; If the boolean expression evaluates true, the first expression is evaluated, otherwise the second expression is evaluated. A typical usage of this operator is to return the larger (or smaller) of two values of type T: template<typename T> T max (T a, T b) {return a<b ? b : a}; template<typename T> T min (T a, T b) {return a<b ? a : b}; These are really nothing more than notational shorthand for the following: template<typename T> T max (T a, T b) {if (a<b) return b; else return a; }; template<typename T> T min (T a, T b) {if (a<b) return a; else return b;}; However, because ternary expressions are evaluated, the return value of the expression can be used in more complex expressions: int a=42, b=0; // ... int c = ((a>b ? a : b) = 1); In the above expression, whichever is the larger of a and b will be assigned the value 1 which will also be assigned to c. Thus a and c become 1 while b remains 0.


Do you have to sign for fedex shipping mail?

This all depends on what the shipper requests. If the shipper requires no signature then no you dont have to sign. If the shipper requires an indirect signature, then you can sign in person for the package or if you miss the driver you can sign the bottom of your doortag, and on the next attempt the driver will leave the package. If the shipper requires a direct signature then someone would need to be present to sign for the package at time of delivery. And last if the shipper requires an adult signature, then someone of the age of 21yrs or older, with valid id would have to sign for the package at the time of delivery. **Any package that has a declared value of $500 or more, will automatically require a direct signature, no matter if the shipper requires it or not.


What is the name of the display feature that highlights are of the screen which requires operator attention?

reverse video


Which vessel requires that the operator be at least fourteen years of age on Washington waters?

Sailboat


Does an owner operator need a cdl license?

If the vehicle requires a CDL to be operated, then yes. An owner/operator is subject to the same licencing requirements as a company driver.


What is dd form 1502-1?

unclassified cargo that requires signature service is known as


What is a CDL driver?

A person who operates a vehicle which requires the operator to possess a Commercial Drivers Licence.