سلام
test.h
#include <string>
#include <cstring>
#ifndef TEST_H
#define TEST_H
using namespace std;
class Test
{
private:
string name ;
public:
Test(string n);
void show();
void set();
};
#endif // TEST_H
test.cpp
#include <iostream>
#include "test.h"
using namespace std;
Test::Test(string n): name(n) {}
void Test::set()
{
cout << "plz enter name :\n" ;
getline(cin,name);
if(name.length() >= 25 )
name = name.substr(0,25);
}
void Test::show()
{
cout << "Your name : " << name << endl ;
}
main
#include <iostream>
#include "test.h"
using namespace std;
int main()
{
Test t1("Test"), t2 ;
t2.set();
t1.show();
t2.show();
return 0;
}
توی main خط 9 ارور میده :
/home/test/Documents/Test/Test/main.cpp:9: error: no matching function for call to 'Test::Test()'