//This is class for Linked list
class SinglyLinkedListNode {
public:
int data;
SinglyLinkedListNode *next;
SinglyLinkedListNode(int node_data) {
this->data = node_data;
this->next = nullptr;
}
};
SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* head, int key )
{
SinglyLinkedListNode* newNode = &SinglyLinkedListNode(key);
/*1st way of creating a node sing a class constructor
error(i got for this) :error: taking address of temporary [-fpermissive]
*/
SinglyLinkedListNode* newNode = new(SinglyLinkedListNode );//2nd way of creating a node
newNode->data=key;
newNode->next=NULL;//following error i got by second method
/*solution.cc:59:66: error: no matching function for call to ‘SinglyLinkedListNode::SinglyLinkedListNode()’
SinglyLinkedListNode* newNode = new(SinglyLinkedListNode );//2nd way of creating a node
^
solution.cc:10:9: note: candidate: ‘SinglyLinkedListNode::SinglyLinkedListNode(int)’
SinglyLinkedListNode(int node_data) {
^~~~~~~~~~~~~~~~~~~~
solution.cc:10:9: note: candidate expects 1 argument, 0 provided
solution.cc:5:7: note: candidate: ‘constexpr SinglyLinkedListNode::SinglyLinkedListNode(const SinglyLinkedListNode&)’
*/
}