0

I am trying to use the "UserAccType" in "UserAccountListType" but the code keeps giving me this error: symbol(s) not found for architecture x86_64. I have tried to use forward declaration and it gave me another error: "field has incomplete type". how to fix this problem and thanks in advance.

Here is a piece of the code:

//UserAccountListType.h
#ifndef USERACCOUNTLISTTYPE_H
#define USERACCOUNTLISTTYPE_H
#include <iostream>
class UserAccType;
class UserAccountNode;
class UserAccountListType
{
private:
    UserAccountNode *first;
    UserAccountNode *last;
    int counter;

public:
    UserAccountListType()
    {

        first = last = NULL;
        counter = 0;
    }
    void destroyList();
    void print() const;
    void insertUserAccount(const UserAccType newItem);
    void deleteUserAccount(std::string ud);
    void printInfoOfUserId(std::string userId);
    bool isUserIdExist(std::string ud);
    ~UserAccountListType()
    {
        destroyList();
    }
};
#endif




//UserAccType.h

#include <iostream>
#ifndef USERACCTYPE_H
#define USERACCTYPE_H
class UserAccType
{
private:
    std::string userId;
    std::string password;
    std::string firstName;
    std::string lastName;
    std::string encryptedPassword;

public:
    UserAccType(std::string userId = "", std::string password = "", std::string firstName = "", std::string lastName = "")
    {
        this->firstName = firstName;
        this->lastName = lastName;
        this->password = password;
        this->userId = userId;
    }

    void setUserId(std::string);
    void setpassword(std::string);
    void setFirstName(std::string);
    void setLastName(std::string);
    std::string getUserId();
    bool isCompleteUserACC();
    std::string encryptPassword(std::string);
    void printUserInfo();
    bool isValidPassword(std::string Password);
};
#endif
Ayoub
  • 17
  • 6
  • Passing an instance of an object by value `void insertUserAccount(const UserAccType newItem);` requires the object to be complete. You could use a pointer or reference instead. – Retired Ninja Dec 26 '21 at 23:03
  • @RetiredNinja still same error ' "UserAccountListType::UserAccountListType()", referenced from: _main in main-f3d9ae.o "UserAccountListType::~UserAccountListType()", referenced from: _main in main-f3d9ae.o ld: symbol(s) not found for architecture x86_64' – Ayoub Dec 26 '21 at 23:12
  • The linker error is a different problem. What compiler are you using and how are you compiling this? – Retired Ninja Dec 27 '21 at 00:55
  • @RetiredNinja I use "g++ main.cpp" – Ayoub Dec 27 '21 at 04:03
  • How many other cpp files do you have? Those need to be compiled and linked as well. – Retired Ninja Dec 27 '21 at 13:58
  • @RetiredNinja 3 files can you tell me how to compile and link them – Ayoub Dec 28 '21 at 03:41
  • 1
    `g++ main.cpp 2.cpp 3.cpp -o programname` should work. If it gets more complicated later you could look into creating a makefile. They can be a bit intimidating but this might help you get started: https://stackoverflow.com/questions/2481269/how-to-make-a-simple-c-makefile There are plenty of other question and answers about them too. Good luck! – Retired Ninja Dec 28 '21 at 04:03

0 Answers0