answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

What is the valid class declaration header for the derived class d with base classes b1 and b2 A class d public b1 public b2 B class d class b1 class b2 C class d public b1 b2 D class d b1 b2?

What is the valid class declaration header for the derived class d with base classes b1 and b2?A. class d : public b1, public b2 {/*...*/};B. class d : class b1, class b2 {/*...*/};C. class d : public b1, b2 {/*...*/};D. class d : b1, b2 {/*...*/};The answer is A, C and D.B is not valid because "class" is not a valid access specifier.All the others are valid because private access is the default when the access specifier is omitted. Note that if class D were declared using the struct prefix, inheritance would default to public access rather than private.


Is it better to be a B1 or a B2 aircraft maintenance engineer?

g


What is single inheritance in c plus plus?

Multiple inheritance occurs when a class is derived directly from two or more base classes. class b1 {}; class b2 {}; class d: public b1, public b2 {}; // multiple inheritance class


What is object slicing in c plus plus?

Object slicing typically occurs when operating upon a base class reference, even when the reference is actually an instance of a derived class. You might expect polymorphic behaviour but it doesn't happen, due to object slicing. Most of the time this is only to be expected (such as when passing a derived object to a base class copy constructor or assignment operator), but when you actually expect polymorphic behaviour it can catch you out. The following example of partial assignment demonstrates this:#includestruct A {int a_var;A(int a): a_var(a) {}void debug() { std::cout


When do you make class virtual?

Whenever a derived class requires direct inheritance from a base class, even if it inherits that base class indirectly. That is, if V is a base class from which B is derived, and D is derived from B, then D inherits from V indirectly (through B). But if B is virtually derived from V, then D will inherit directly from V. This feature is commonly used in conjunction with multiple inheritance. Examine the following declarations: class V{}; class B1: public V{}; class B2: public V{}; class M: public B1, public B2{}; Now suppose you have the following code: M m; // Declare an instance of M. V& v = m; // Ambiguous... The problem with this is that M inherits V from both B1 and B2, and therefore inherits two separate instances of V. The compiler is unable to determine which instance of V you want to refer to. One solution to this would be to use static casts to indirectly refer to an explicit instance of V: V& v = static_cast<B1&>(m); or V& v = static_cast<B2&>(m); While this is certainly workable, it is an ugly approach that places far too much responsibility upon the programmer to ensure the correct instance of V is being referred to. However, unless there is a specific need to have two instances of V within M, the problem can be resolved with virtual inheritance. By virtually deriving both B1 and B2 from V, M will directly inherit just one instance of V, which is then shared, virtually, between B1 and B2: class V{}; class B1: public virtual V{}; class B2: public virtual V{}; class M: public B1, public B2{}; M m; V& v = m; // No ambiguity. Now M can access all the members of V directly, as can B1 and B2, because they now share the same instance of V. Note that it doesn't matter whether the virtual keyword is placed before or after the access specifier (which is public in this case). "virtual public" and "public virtual" have the same meaning.

Related Questions

What is the difference between a B1/B2 visa and a B2 visa?

A B1/B2 visa allows for both business (B1) and tourism (B2) purposes, while a B2 visa is specifically for tourism and visiting friends or family in the United States.


What is the difference between a B2 visa and a B1/B2 visa?

A B2 visa is for tourism or medical treatment, while a B1/B2 visa allows for both business and tourism purposes.


What is the difference between a B1 and B2 visa?

A B1 visa is for business travel, while a B2 visa is for tourism or visiting family and friends.


What are the key differences between a B1 and B2 visa?

A B1 visa is for business purposes, while a B2 visa is for tourism or medical treatment.


What's the difference between a B1 and B2 visa?

A B1 visa is for business travel, while a B2 visa is for tourism or visiting family and friends.


Can I work on a B1/B2 visa"?

No, you cannot work on a B1/B2 visa.


Are you able to work on a B1/B2 visa"?

Yes, you can work on a B1/B2 visa.


Can I work in the USA with a B1/B2 visa"?

No, a B1/B2 visa does not allow you to work in the USA.


For how long is a B1/B2 visa valid?

A B1/B2 visa is typically valid for 10 years.


How long is a B1/B2 visa valid for?

A B1/B2 visa is typically valid for 10 years.


What are the key differences between a B1/B2 visa and a B2 visa, and how do these distinctions impact the purposes and activities allowed for visitors under each visa category?

A B1/B2 visa allows for both business (B1) and tourism (B2) purposes, while a B2 visa is solely for tourism. The distinction impacts the activities allowed, with B1/B2 visa holders able to engage in business-related activities in addition to tourism, while B2 visa holders are limited to tourism activities only.


Can a person with a B1/B2 visa work in the USA?

No, a person with a B1/B2 visa is not allowed to work in the USA.