Getting Incomplete Type Error when trying to create a new object in cpp

This is my first time posting, so sorry if there's any issues with my formatting or wording. As the title says though, I've just been getting started working on an assignment and found an issue when trying to create an object instance of a class. I'm trying to create the object in a cpp file I'll be using for testing. The error is "incomplete type not allowed"

There are three files: Process.h, Process.cpp, and test.cpp. The code for each is below.

Process.h

#include <iostream>
#include <string>

using namespace std;

class Process {

private:

    int ProcessID;
    string ProcessState;


public:

    //constuctor
    Process(int, string);

    //mutator functions
    void SetProcessID(int);
    void SetProcessState(string);

    //accessor functions
    int GetProcessID();
    string GetProcessState();

};

Process.cpp

#include <iostream>
#include "Process.h"

//constructor
Process::Process(int Id, string State)
{
    SetProcessID(Id);
    SetProcessState(State);
}

//mutator
void Process::SetProcessID(int Id)
{
    ProcessID = Id;
    return;
}.....

Test.cpp

#include <iostream>
#include "Process.h"

using namespace std;

class Process;

int main()
{
    Process Process1(1, "Ready"); //Error here on this line

    cout << "Process 1 created" << endl;

}

I have tried to replace the error line in the test.cpp with Process* Process1(1, "Ready"); or Process Process1 = new Process(1, "Ready"); and variations of these, as well as trying to switch around the includes but to no avail. I'm working in Visual Studio 2019 and it seems that the test.cpp is aware of the Process class but something (the constructor, maybe?) is out of its scope for some reason. Running the test.cpp code in the Process.cpp file works as intended as well, but I need to be able to call it in other files.

Any help would be appreciated! Thank you!



from Recent Questions - Stack Overflow https://ift.tt/39ejAnC
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)