0

Возникла проблема при сплите класса на объявление в header файле, и реализацию в cpp файле:

main.cpp

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

int main() { Test a;

a.Print();

return 0;

}

Test.h

#pragma once

class Test { private: int* data; public: Test();

~Test();

void Print();

};

Test.cpp

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

Test::Test(){ int* data = new int(0); }

Test::~Test(){ delete data; }

void Test::Print(){ std::cout << *data << std::endl; }

И при сборке main.cpp выдается ошибка undefined referenceу каждого метода класса. Честно говоря не понимаю почему так происходит. Заранее спасибо за ответ!

michk4
  • 55

0 Answers0