小编Lor*_*nas的帖子

错误"C++在定义方法时需要所有声明的类型说明符"

我对C++比较陌生(所以请尽量保持答案简单!),我无法理解为什么会出现错误: C++ requires a type specifier for all declarations whilst defining methods.

我正在尝试编写一个简单的程序来逐行读取文本文件,将值存储到数组中.但是,当我尝试在.cpp文件中声明方法时,我遇到了一个问题.请在下面找到代码.

StringList.h

#ifndef StringListH
#define StringListH

#include <vector>
#include <string>

class StringList {
public:
     StringList();
     ~StringList();
     void PrintWords();
private:
     size_t numberOfLines;
     std::vector<std::string> str;
};

#endif
Run Code Online (Sandbox Code Playgroud)

StringList.cpp

#include "StringList.h"
#include <fstream>
#include <istream>
#include <algorithm> // std::copy
#include <iterator>  // istream_iterator

using namespace std;

StringList::StringList()
{
    ifstream myfile("input.in");
    if (myfile.is_open())
    {
        copy(
            istream_iterator<string>(myfile),
            istream_iterator<string>(),
            back_inserter(str));
    }
    numberOfLines = str.size();
}

StringList::~StringList(){
    //Deconstructor
}

// Error Happens Here
StringList::PrintWords(){
    //Print …
Run Code Online (Sandbox Code Playgroud)

c++ oop class header-files

16
推荐指数
3
解决办法
6万
查看次数

从 HTML5 表单中获取日期 - 并发布到 MySQL

我有一个基本的 Web 表单,我需要从“日期”类型输入(html5 参见http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_type_date)中获取日期并将其发布到我的 MySQL 数据库(具有 DATE 类型 - 注意:不是 DATETIME)。

我需要某种 PHP/JS 巫术来让 2 互相交谈,有任何线索吗?

继承人到目前为止我所得到的,它总是产生 1970-01-01 的默认日期。

将其作为普通输入并使用 Jquery 强制格式会更好吗?

<!-- zee form: -->
<div>
    <!-- Start Date -->
    <div>
        <label class="col-offset-half col-3" for="order_contractStart">Contract Start:</label>
        <input class="col-offset-half col-7" type="date" id="order_contractStart" name="order_contractStart">
    </div>
    <!-- End Date -->
    <div>
        <label class="col-offset-half col-3" for="order_contractEnd">Contract End:</label>
        <input class="col-offset-half col-7" type="date" id="order_contractEnd" name="order_contractEnd">
    </div>
Run Code Online (Sandbox Code Playgroud)

然后在我的行动中,我有:

//Get Variables from form
$start = date("Y-m-d", $_GET['order_start']);
$end = date("Y-m-d", $_GET['order_end']);
Run Code Online (Sandbox Code Playgroud)

事实证明这种方法并没有真正起作用 - 所以任何指针都将不胜感激。

html php mysql forms date

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

class ×1

date ×1

forms ×1

header-files ×1

html ×1

mysql ×1

oop ×1

php ×1