Answers for "syntax of constructor in c++"

C++
0

struct constructor in c++

# Definition of a singly linked list
struct ListNode {
	int val;	
	ListNode *next;
  
 	ListNode() : val(0), next(nullptr) {}
  	ListNode(int x) : val(x), next(nullptr) {}
 	ListNode(int x, ListNode *next) : val(x), next(next) {}
};
Posted by: Guest on December-01-2021
0

C++ constructor

class Book {public:    Book(const char*);    ~Book();    void display();private:    char* name;};
Posted by: Guest on June-20-2021

Browse Popular Code Answers by Language