Results 1 to 5 of 5

Thread: Use of the back() in C++

  1. #1
    Join Date
    Jan 2010
    Posts
    22

    Use of the back() in C++

    Hello, I am studying in the ABC college. I had just started to learn C++ language from the institute. I am interested in the programming and I had heard that the C++ language can be the very simple programming language. So, I would like to know about the back() function of the C++ language. Also, I would like to know about the use of the back() function in the C++ programming. Can anyone has the solution for me on the back() function. Reply Me!!!

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Use of the back() in C++

    The back() function can be used to execute the last element in the given specified queue. The back() function can returns a address to the last element in the given specified queue. That can be the newest element in the given specified queue that is the last element that can be pushed into the queue. The back() function of the C++ language can be the member function of the queue.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Use of the back() in C++

    The program that can be mentioned below illustrates you about how to use the back() function in the C++ language programming :
    Code:
    #include <iostream>
    #include <queue>
    using namespace std;
    int main ()
    {
      queue<int> mque;
      mque.push(12);
      mque.push(75);   
      mque.back() -= mque.front();
      cout << "mque.back() is now " << mque.back() << endl;
      return 0;
    }
    Output:
    Code:
    mque.back() is now 63

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Use of the back() in C++

    The back() function can be used to give the address of the last element that can be in the given specified queue. The back() function can be the member type value_type and that can be specified to the type of value consisted by the belonging class, that shall be the similar as the first template parameter (S). The back() function can be the member function of the queue class of the C++ language.

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Use of the back() in C++

    The back() function can returns a address to the last element that can be in the given specified queue. For an example:
    Code:
      queue<int> p;
       for( int j = 0; j < 5; j++ ) 
       {
         p.push(j);
       }
       cout << "The first element is " << p.front()
            << " and the last element is " << p.back() << endl;
    This code produces the following output:
    Code:
       The first element is 0 and the last element is 4
    The back() function can be executed in the constant time.

Similar Threads

  1. How do I go back to IE7, I have IE8
    By Techmates in forum Technology & Internet
    Replies: 4
    Last Post: 15-03-2011, 02:46 AM
  2. Help me get back to AMD: Phenom x6
    By Marjorie in forum Motherboard Processor & RAM
    Replies: 5
    Last Post: 16-09-2010, 03:52 AM
  3. Replies: 5
    Last Post: 07-09-2010, 12:01 AM
  4. Back to SP2
    By Darth in forum Operating Systems
    Replies: 2
    Last Post: 11-11-2008, 06:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,659,213.16217 seconds with 17 queries