Reputation: 325
d.cpp file:
#include "file.hpp"
#include <iostream>
using namespace std;
int main() {
ns::T t ("ssssss");
}
file.hpp
using namespace std;
namespace ns{
struct T{
T(string s);
};
};
Why do I get this errors?:
file.hpp:8:20: error: expected ‘)’ before ‘s’ T(string s);
d.cpp: In function ‘int main()’: d.cpp:14:26: error: no matching function for call to ‘ns::T::T(const char [6])’ ns::T t ("ssssss"); In file included from d.cpp:8: file.hpp:6:12: note: candidate: ‘constexpr ns::T::T()’ struct T{
Upvotes: 1
Views: 115
Reputation: 1758
You need to include "string":
#include <string>
using namespace std;
namespace ns{
struct T{
T(string s);
};
}
Upvotes: 2