gpt4 book ai didi

C++ 命名空间未声明但它是?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:05:41 25 4
gpt4 key购买 nike

我遇到了编译时问题。 C++ 的新手,所以我确信它很简单。我正在解决当前错误。

diarydb.cpp: In function ‘bool editdate(int, mysqlpp::Connection&)’: diarydb.cpp:413:
error: ‘format_tests’ has not been declared

但是 diardby.cpp 我在这里声明了 format_tests

namespace format_tests {
bool testdateformat(string &date);
bool tesettimeformat(string &time);
bool lengthcheck(string &in,int length);

}

bool format_tests::testdateformat(string &date){
// tests format of dat input for MYSQL form at of YYYY-MM-DD
// Need to tweak regex to restrict 0 < MM < 12 and 0 < DD <31.

const boost::regex e("\\d{4}\\x2D\\d{2}\\x2D\\d{2}");
return boost::regex_match(date,e);
}

此处调用的编译器compler。

  bool dbsetget::editdate(int e_id,mysqlpp::Connection &con){

char evdate[11];

cout << "Input start time" << endl;
cin.getline(evdate,11,'\n'); // restrict legth of input with getline.lenght of input

string date = evdate;

if (format_tests::testdateformat(date)){
mysqlpp::Query query = con.query();
query <<"UPDATE main SET date="<< quote_only << date <<"WHERE d_Id ="<< e_id;

return query.exec();
}
else
{
cerr << "Date not in correct format. YYYY-MM-DD ";
return false;
};
}

我不明白这是什么问题?我已经声明了 format_tests 命名空间 谁能指导我吗?

我敢肯定这里也有很多错误,但这一个让我很困惑。

最佳答案

看起来像你的文件

format_tests::testdateformat(date)

看不到

namespace format_tests
{
bool testdateformat(string &date);
};

您是否包含声明了 testdateformat 的头文件?

关于C++ 命名空间未声明但它是?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5004011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com