Конструктор сборки CppCMS & amp; декларация

От http://cppcms.com/wikipp/en/page/cppcms_1x_forms,

В соответствии с этот,

Объявление вводит одно или несколько имен в программу …..
Следовательно, классы, структуры, перечисляемые типы и другие
пользовательские типы могут быть объявлены для каждой единицы компиляции

AFAIK, конструктор должен быть в myapp.cppв то время как декларация должна быть в content.h, Итак, я положил

В форме есть 5 полей. В CppCMS форма построена с использованием 3 кодов (4-е коды являются ограничением для полей)

1-е коды:

name.message("Your Name");
sex.message("Sex");
marital.message("Marital Status");
age.message("Your Age");
submit.value("Send");

2-е коды:

add(name);
add(sex);
add(marital);
add(age);
add(submit);

3-е коды:

sex.add("Male","male");
sex.add("Female","female");
marital.add("Single","single");
marital.add("Married","married");
marital.add("Divorced","divorced");

4-е коды, это ограничение для полей:

name.non_empty();
age.range(0,120);

Я совершенно запутался, какой из них должен быть декларацией

——————добавленной

Я попытался добавить все вышеуказанные коды в myapp.cpp как ниже:

class myapp : public cppcms::application {
public:
myapp(cppcms::service &srv) : cppcms::application(srv)
{
dispatcher().assign("",&myapp::info_form,this);
mapper().assign("");
}
void info_form()
{
name.message("Your Name");
sex.message("Sex");
marital.message("Marital Status");
age.message("Your Age");
submit.value("Send");

add(name);
add(sex);
add(marital);
add(age);
add(submit);

sex.add("Male","male");
sex.add("Female","female");
marital.add("Single","single");
marital.add("Married","married");
marital.add("Divorced","divorced");

name.non_empty();
age.range(0,120);
}
};

Но это все равно дает ошибку:

myapp.cpp: In member function ‘void myapp::info_form()’:
myapp.cpp:20:9: error: ‘name’ was not declared in this scope
myapp.cpp:21:9: error: ‘sex’ was not declared in this scope
myapp.cpp:22:9: error: ‘marital’ was not declared in this scope
myapp.cpp:23:9: error: ‘age’ was not declared in this scope
myapp.cpp:24:9: error: ‘submit’ was not declared in this scope
myapp.cpp:24:9: note: suggested alternative:
/usr/local/include/cppcms/form.h:1574:20: note:   ‘cppcms::widgets::submit’
myapp.cpp: At global scope:
myapp.cpp:43:37: error: no ‘void myapp::main(std::string)’ member function declared in class ‘myapp’
my_skin.tmpl:4:2: error: expected unqualified-id before ‘if’
my_skin.tmpl:8:3: error: expected unqualified-id before ‘else’
my_skin.tmpl:12:8: error: expected constructor, destructor, or type conversion before ‘<<’ token
my_skin.tmpl:13:2: error: expected unqualified-id before ‘{’ token

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …