Here you will find more than 50000 job interview questions

Job Questions Search Engine


Sponsored Links

Write a sample C++ STL List Program

July 6, 2010 by bigboss · Leave a Comment
Filed under: C++ Interview Questions 

#include <iostream>
#include <vector>
#include <string>

using namespace std;

main()
{
vector<string> SS;

SS.push_back(“The number is 10″);
SS.push_back(“The number is 20″);
SS.push_back(“The number is 30″);

cout << “Loop by index:” << endl;

int ii;
for(ii=0; ii < SS.size(); ii++)
{
cout << SS[ii] << endl;
}

cout << endl << “Constant Iterator:” << endl;

vector<string>::const_iterator cii;
for(cii=SS.begin(); cii!=SS.end(); cii++)
{
cout << *cii << endl;
}

cout << endl << “Reverse Iterator:” << endl;

vector<string>::reverse_iterator rii;
for(rii=SS.rbegin(); rii!=SS.rend(); ++rii)
{
cout << *rii << endl;
}

cout << endl << “Sample Output:” << endl;

cout << SS.size() << endl;
cout << SS[2] << endl;

swap(SS[0], SS[2]);
cout << SS[2] << endl;
}

What are the STL Lists modifier,Iterator and operations

July 5, 2010 by bigboss · Leave a Comment
Filed under: Sample Interview Questions 

Iterators:
begin        Return iterator to beginning (public member function)
end        Return iterator to end (public member function)
rbegin        Return reverse iterator to reverse beginning (public member function)
rend        Return reverse iterator to reverse end (public member function)

Capacity:
empty        Test whether container is empty (public member function)
size        Return size (public member function)
max_size    Return maximum size (public member function)
resize        change size (public member function)

Element access:
front    Access first element (public member function)
back    Access last element (public member function)

Modifiers:
assign        Assign new content to container (public member function)
push_front    Insert element at beginning (public member function)
pop_front    Delete first element (public member function)
push_back    Add element at the end (public member function)
pop_back    Delete last element (public member function)
insert        Insert elements (public member function)
erase        Erase elements (public member function)
swap        Swap content (public member function)
clear        Clear content (public member function)

Operations:
splice        Move elements from list to list (public member function)
remove        Remove elements with specific value (public member function)
remove_if    Remove elements fulfilling condition (public member function template)
unique        Remove duplicate values (member function)
merge        Merge sorted lists (public member function)
sort        Sort elements in container (public member function)
reverse        Reverse the order of elements (public member function)

Allocator:
get_allocator    Get allocator (public member function)

  • Categories

    |
  • Tags

    ADO.NET Questions Algorithm Questions ASP.NET Questions auto_ptr Binary tree questions C++ Constructor Interview Questions C++ Questions CISCO Exams Questions Common Interview Questions Core Java Interview Questions Csharp Questions datastructure questions Delphi 6 find command gdb interview questions grep interview questions IBM certification exams questions Infosys Puzzles Java Struts Linked List Problem Linux Command Questions List Manager Interview Questions Markov Algorithm memory leakage mysql Interview Questions Normalization Oracle Application Developer Certification Exam Interview Questions Oracle Questions Perl Questions PHP Questions Pointers Interview Questions PostgreSQL Database Questions pthread interview questions Smart Pointer Solaris Interview Questions SQL SERVER Interview Questions STL STL Map Symbian OS Tricky Interview Questions Unix Interview Questions unix shell Vector Windows OS Questions