Я пытаюсь создать класс в отдельных файлах с частными переменными. На данный момент мой код классов:
В TestClass.h
#ifndef TESTCLASS_H
#define TESTCLASS_H
#include <string>
using namespace std;
class TestClass
{
private:
string hi;
public:
TestClass(string x);
void set(string x);
void print(int x);
};
#endif
В TestClass.cpp
#include "TestClass.h"
#include <iostream>
#include <string>
using namespace std;
TestClass::TestClass(string x)
{
cout << "constuct " << x << endl;
}
void set(string x){
hi = x;
}
void print(int x){
if(x == 2)
cout << hi << " x = two\n";
else if(x < -10)
cout << hi << " x < -10\n";
else if(x >= 10)
cout << hi << " x >= 10\n";
else
cout << hi << " x = " << x << endl;
}
Когда я пытаюсь создать Code :: Blocks, он говорит:
Но когда я ее запускаю (и не собираю), все работает.