I'm trying to learn as much C++ as I can. I was writing a program that mixes linked lists and classes. There is the class "Obj" which only holds an integer called 'data' and the classic "struct node" structure for linked list, but this time the "node" structure will hold an instance of "Obj" Class and the next* pointer.
#include <iostream>
usingnamespace std;
class Obj
{
private:
int data;
public:
Obj(int d): data(d) {}
void getData() {cout<<data<<endl;}
};
struct node
{
Obj o;
node* next;
};
int main()
{
node* n=new node; //I receive "Call to implicity-deleted default constructor of 'node'" here
}
Unfortunately I'm not able to create a new node because of the error I mention. Do you know what is the problem here? Perhaps is something really stupid to ask this but I literally hit my head against the desk trying to find out the solution.