C++ - Unknown type name

31 Views Asked by At

I have this problem while running C++ headers files on VS code on mac, my computer is new so I don't know if that is causing the problem. Basically, I need to read header files to have object from another class in my class but I'm getting this error, 'unknown type name 'Accounts' ' in my customer.h file when I run my driver that includes both classes. Could this be related to the fact that they have objects of each other? Or maybe it's a json issue? in my code I commented exactly where the errors are ocurring.

Any help would be greatly appreciated.

now, my customer.h

#pragma once
#include "Accounts.h"
#ifndef CUSTOMER_H
#define CUSTOMER_H


#include <string>

class Customer {

private:
    int id;
    std::string name;
    std::string lastName;
    std::string adress;
    int phoneNum;
    std::string email;
    Accounts *accounts; // this is the one thats not being read by compiler
    int numOfAccounts; 
    

public:

    // all my functions
    
    void addAccount(Accounts&); // this is the one thats not being read by compiler
    


};
#endif // !CUSTOMER_H

accounts.h

#pragma once
#include <string>
#ifndef ACCOUNTS_H 
#define ACCOUNTS_H
#include "customer.h"

class Accounts{


protected:              //Potected used instead if private since I'm going to inherit from this class later.
    int AccountNum;
    double Balance;
    double TransFee;
    Customer customer;     //Customer dynamic object linked to each account.
    

public:
//all my functions

}; 

#endif // !ACCOUNTS_H 
0

There are 0 best solutions below