answersLogoWhite

0

glass tumler

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

How do you convert integer to objects in c?

There are no objects in C, so you can't. However, in C++ you can convert an integer to an object if the object's class exposes a public conversion constructor that accepts an integer argument. For example: class X { public: X (int); // conversion constructor // ... }; How the conversion is implemented depends on the class designer. In the following example, a user can construct a complex number type from an integer: class complex { private: double r; double i; public: complex (double real, double imaginary): r {real}, i {imaginary} {} complex (int real): r {real}, i {0.0} {} // ... }; Here, the implementation implicitly converts the integer to a double and assigns that value to the real representation and assigns the value 0.00 to the imaginary representation. This class may be used as follows: complex c = 42; // e.g., c.r = 42.0, c.i = 0.0 If a conversion constructor is provided, a corresponding conversion assignment is usually provided as well: class complex { private: double r; double i; public: complex (double real, double imaginary): r {real}, i {imaginary} {} complex (int real): r {real}, i {0.0} {} complex& operator= (int real) { r = real; i = 0.0; } // ... }; This class may be used as follows: complex c {1.1, -3.14}; // ... c = 42; // e.g., c.r = 42.0, c.i = 0.0


What is the difference between a queue and a stack?

Queue is better than stack because jobs in a queue are processed on a first in first out order thereby reducing traffic and delay. But jobs in a stack are processed in a last in first out order causing traffic and delay of jobs that arrived earlier


What is a linear queue?

A linear queue models the FIFO(first in first out) data structure, much like a line in real life. The first person in line will be the first person served, in queues the first element to be added is the first that can be removed. The only adding point is to the end of the list and the only removal point is the beginning of the list. Queue<String> q = new LinkedList<String>(); // The LinkedList class implements Queue q.add("Bob"); // Now Bob is at the front of the queue q.add("Stacy"); // Stacy after Bob q.add("Will"); // and Will after her String removed = q.remove(); // Bob is removed q.add("Michael"); Michael is added after Will System.out.println(q); // Prints ["Stacy", "Will", "Michael"]


What is the algorithm for inserting values into a queue in c plus plus?

A queue usually infers first in first out (FIFO), therefore new values will need to be inserted after the last node (the tail node) and the queue must maintain pointers to both the head node for extraction and the tail node for insertion, and each node must maintain a pointer to the next node in the queue (singly-linked list). The following code provides a bare-bones implementation of a singly-linked FIFO list, where each value is an integer. In real-life you'd use one of the built-in class templates, otherwise you'd have to re-write the same code to cater for all the different value types you might want to place in a queue (or create your own class template). However, the example serves to show the algorithm that is used to insert new values to the end of a queue. It does not show how to extract the first node from the queue. #include <iostream> using namespace std; class Node { public: Node( int iValue ):m_iValue( iValue ),m_pNext( NULL ){} ~Node(){ if( m_pNext ) delete m_pNext; } Node * GetNext()const{ return m_pNext; } void SetNext(Node * pNext ){ m_pNext = pNext; } int GetValue()const{ return m_iValue; } private: Node * m_pNext; int m_iValue; }; class Queue { public: Queue():m_pFirst(NULL),m_pLast(NULL){} ~Queue(){ if( m_pFirst ) delete m_pFirst; } Node * GetFirst()const{ return m_pFirst; } Node * GetLast()const{ return m_pLast; } void Insert( int iValue ); void ShowAll()const; private: Node * m_pFirst; Node * m_pLast; }; void Queue::Insert( int iValue ) { Node * pNew = new Node( iValue ); if( m_pLast ) m_pLast->SetNext( pNew ); else m_pFirst = pNew; m_pLast = pNew; } void Queue::ShowAll() const { Node * pNode = m_pFirst; while( pNode ) { cout << pNode->GetValue(); if( pNode != m_pLast ) cout << ", "; pNode = pNode->GetNext(); } cout << endl << endl; } int main() { Queue queue; queue.Insert( 2 ); queue.Insert( 1 ); queue.Insert( 3 ); queue.ShowAll(); return( 0 ); }


When you use decimal which type of data is it?

Decimal numbers are real numbers. In C and C++ we use the float, double and long double data types to represent real numbers.

Related Questions

List out atleast 5 real life instances where queue and circular queue operations are being used?

A>People will stand on queue for getting a film tickets. B>In Airport the luggage will be flowing in a queue manner. C>Children will walk into the school in queue. D>Getting into the temple we have to stand in a queue. E>School children will do the prayer with a proper queue.


What is the queue concept in computer system?

It's very similar to real-world queues. Queues can be used for various purposes. For example if there are multiple tasks that are waiting to be executed, then they will wait in a queue for their turn to come. Another use is when some resource (say your printer) is needed by various tasks for their successful and complete execution. These tasks will then wait in the queue for their turn as each task in front of them uses and releases the printer and then exits the queue. Basically a queue is a First In First Out (FIFO) structure. This means, that like real-world queues, the first task to enter the queue will be the first to execute or obtain its required resources. Any other tasks that come after it are added to the rear end of the queue and from there they move to the front of the queue one-by-one as their turn comes up. Hope that helps.


When did For Real end?

For Real ended in 1999.


Give atleast 5 real life examples of circular queue?

Application of queue- 1. Task waiting for line printer 2.Time sharing by CPU 3.access to disk storage.. I am not able to find out any application of circular queue..It would be great if anybody help me out


Can circular queue be used in real life situations?

yes it can be used in real life situations take a batch of colddrinks at colddrink factory when they are packed.they are inserted into circular queue &when any one colddrink is ready then it is not yet selected by machine but machine fetched bottles of colddink in that order in which they are inserted


When did Mozambican real end?

Mozambican real ended in 1914.


When did Venezuelan real end?

Venezuelan real ended in 1837.


When did Real Robots end?

Real Robots ended in 2005.


When did Colombian real end?

Colombian real ended in 1837.


When did Paraguayan real end?

Paraguayan real ended in 1856.


When did Gibraltar real end?

Gibraltar real ended in 1898.


When did Azorean real end?

Azorean real ended in 1911.