0

I have two classes Task and TaskDate. It seems like visual studio doesn't see TaskDate. Did I do something wrong or why doesn't it seem to find it? I get the error at line 11: 'date':unknown override specifier, like date wouldn't have a type

This is Task.h

#ifndef TASK_H
#define TASK_H
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include "TaskDate.h"

class Task
{
private:
    std::string id, title, type, status;
    TaskDate date;

public:
    Task();
    virtual ~Task();
    Task(std::string id, std::string title, std::string type, std::string status, TaskDate date);

    std::string getTaskID() { return id; }

    std::string getTitle() { return title; }

    std::string getType() { return type; }

    std::string getStatus() { return status; }
    
    TaskDate getDate() { return date; }

    std::string toString();
};

#endif

This is TaskDate.h

#ifndef TASKDATE_H
#define TASKDATE_H

#include "Task.h"


class TaskDate
{
public:
    int day;
    int month;
    int year;
    TaskDate();
    TaskDate(int nday, int  nmonth, int  nyear);
};
#endif
  • 1
    TaskDate.h `#defines` TASKDATE_H then includes the other header file. The other header flie `#includes` TaskDate.h again, but because `TASKDATE_H` is already defined, the end result is a big, fat, goose egg. Grand Total: `TaskDate` gets used, in the other header file, before it's ever defined. See the linked question for more information. – Sam Varshavchik Jun 30 '20 at 22:22
  • Why does TaskDate.h need to include Task.h? From the supplied example it does not need that. – drescherjm Jun 30 '20 at 22:26
  • @drescherjm, it doesn't that was the problem thanks a lot! Could you post that as a response so i can mark it as solved? – RobertChrisstian Jun 30 '20 at 22:30
  • 1
    Since its closed as a duplicate I can't answer. – drescherjm Jun 30 '20 at 22:56

0 Answers0