linkedlist implementation in c++
C++
#include <iostream>
using namespace std;
struct node
{
int data;
node *next;
};
class linked_list
{
private:
node *head,*tail;
public:
linked_list()
{
head = NULL;
tail = NULL;
}
void add_node(int n)
{
node *tmp = new node;
tmp->data = n;
tmp->next = NULL;
if(head == NULL)
{
head = tmp;
tail = tmp;
}
else
{
tail->next = tmp;
tail = tail->next;
}
}
};
int main()
{
linked_list a;
a.add_node(1);
a.add_node(2);
return 0;
}
Also in C++:
- Title
- using namespace std in c++
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- longest common subsequence
- Category
- C++
- Title
- getch c++ library
- Category
- C++
- Title
- first prime numbers
- Category
- C++
- Title
- how to load from files C++
- Category
- C++
- Title
- shortest path with bfs in c++
- Category
- C++
- Title
- : error: ‘cont’ cannot be used as a function return (cont(cont-1))/2;
- Category
- C++
- Title
- how read a shader from another file c++
- Category
- C++
- Title
- matrix eigen c++ example
- Category
- C++
- Title
- c++ initialize array
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- c++ string^ to char*
- Category
- C++
- Title
- unordered_set in c++ and ordered set diff
- Category
- C++
- Title
- set mimetype validation in mongoose
- Category
- C++
- Title
- memset
- Category
- C++
- Title
- c++ for loop syntax
- Category
- C++
- Title
- how do for loops on c++
- Category
- C++
- Title
- initialize 3d vector c++
- Category
- C++
- Title
- cpp pi from acos
- Category
- C++
- Title
- program to know if a number is prime
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- matrix multiplication c++ eigen
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- insert at position in vector c++
- Category
- C++
- Title
- primeros numeros primos
- Category
- C++
- Title
- never gonna give you up
- Category
- C++
- Title
- change int to string cpp
- Category
- C++
- Title
- cpp nan value
- Category
- C++
- Title
- Read multiple files(.txt) c++
- Category
- C++
- Title
- cin.ignore
- Category
- C++
- Title
- least number of coins to form a sum
- Category
- C++
- Title
- c++ string to int
- Category
- C++
- Title
- c++ char print width
- Category
- C++
- Title
- time function c++
- Category
- C++
- Title
- Find the duplicate in an array of N integers.
- Category
- C++
- Title
- initialize vector of vector c++
- Category
- C++
- Title
- c++ ternary operator
- Category
- C++
- Title
- get elements of 2d array c++
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- stringstream in c++
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- sort a pair using c++ stl
- Category
- C++
- Title
- c++ function return pointer to itself
- Category
- C++
- Title
- how to compare lower case character to uppercase cpp
- Category
- C++
- Title
- goto c++
- Category
- C++
- Title
- compare function in sort c++ stl
- Category
- C++
- Title
- to_string c++
- Category
- C++
- Title
- c++ overload operator
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- c++ empty stream
- Category
- C++
- Title
- new class * [] c++
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- C++ w3schools
- Category
- C++
- Title
- single line if c++
- Category
- C++
- Title
- how to use wasd c++
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- c++ function default argument
- Category
- C++
- Title
- if vector contains value c++
- Category
- C++
- Title
- hashmap in c++
- Category
- C++
- Title
- c++ enum rand
- Category
- C++
- Title
- how to reverse a vector
- Category
- C++
- Title
- c++ set add element
- Category
- C++
- Title
- compile c++ program
- Category
- C++
- Title
- c++ function to find length of array
- Category
- C++
- Title
- find vector in c++
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- fill c++
- Category
- C++
- Title
- find upper bound c++ vector
- Category
- C++
- Title
- remove from unordered_set c++
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- string to number in c++
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- strchr function in c++
- Category
- C++
- Title
- 2d vector
- Category
- C++
- Title
- sfml base program
- Category
- C++
- Title
- c++ push multiple elements to vector
- Category
- C++
- Title
- how to sort in descending order c++
- Category
- C++
- Title
- iostream library in cpp
- Category
- C++
- Title
- how to include seld declared header file in c++
- Category
- C++
- Title
- first prime numbers less than
- Category
- C++
- Title
- how to iterate over unordered_map c++
- Category
- C++
- Title
- string to upper c++
- Category
- C++
- Title
- traverse map c++
- Category
- C++
- Title
- map arduino
- Category
- C++
- Title
- cut by delimiter c++
- Category
- C++
- Title
- peak in c++
- Category
- C++
- Title
- cheap hosting
- Category
- C++
- Title
- char vector to string c++
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- c++ program to input and print text using Dynamic Memory Allocation.loop
- Category
- C++
- Title
- maximum subarray sum in c++
- Category
- C++
- Title
- pyqt connect
- Category
- C++
- Title
- array syntax in c++
- Category
- C++
- Title
- int max in c++
- Category
- C++