2

We are having troubles including a login form in our project. We follow the steps in http://cppcms.com/wikipp/en/page/cppcms_1x_forms

This is the definition of the form:

struct SignInFormInfo : public cppcms::form {
/* Error 1 */ cppcms::widgets::text user_name;
/* Error 2 */ cppcms::widgets::password password;
cppcms::widgets::submit submit;

SignInFormInfo() {
user_name.message("User name");
password.message("Password");
submit.value("Sign in");

add(user_name);
add(password);
add(submit);

// Restrictions
user_name.limits(1, 31);
password.non_empty();
}
};

and we get these build errors:

Error 1: The type 'cppcms::widgets::text' must implement the inherited pure virtual method 'cppcms::base_form::load'

Error 2: The type 'cppcms::widgets::password' must implement the inherited pure virtual method 'cppcms::widgets::base_widget::render_input'

We also get errors in the cppcms libraries "cppcms/form.h" and "booster/hold_ptr.h" about the variable "_data" being private.

We are using 1.0.3 version of CppCMS.

Thanks for your help

nico
  • 110
  • 2
  • 8
  • 1
    very interesting question. Should be used as example for inheritance problems :) hope someone else thumbs your question up. Not always there's the chance to see issues like that. – CoffeDeveloper Jan 22 '13 at 20:25
  • 1
    You have something really messed up in installation/compilation, because the code above 100% compiles on CppCMS 1.0.3. The code above with a header `` passes compilation without a single problem. – Artyom Jan 23 '13 at 11:41
  • You are right, "Error 1" and "Error 2" were detected by Eclipse, but not the compiler. The actual error was trying to make a copy of the form. My mistake. Thanks. – nico Jan 23 '13 at 14:08

1 Answers1

0

Wich "load" method should be used?

the one from "base_html_input" class or the one from "base_text". There are 2 methods named "load" that comes from different classes (and both derived from same class!), both are base classes of the same class. The compiler simply don't know wich one to use. The best thing is to implement your self the "load".

widgets::text::load(param) //actually missing in CPPCMS
{
     //wich one of the 2 methods has to be called.. or both have to be called?
     base_html_input.load(param)
     base_text input.load(param);
}

That's probably a design flaw of the library you are using (unless there's somewhere a factory of "widgets::text" objects, that is returning objects with correct implementation, anyway the article with the tutorial is wrong.)

CoffeDeveloper
  • 7,961
  • 3
  • 35
  • 69
  • I did what you suggested, made a custom_widget class (inherits from widgets::text) implementing the load method calling base_text load() method. But now I get this error that seems to be common in C++ but I can't figure out how to solve it. booster/noncopyable.h: In copy constructor ‘cppcms::form::form(const cppcms::form&)’: booster/noncopyable.h:17:3: error: ‘booster::noncopyable::noncopyable(const booster::noncopyable&)’ is private Thanks for your answer – nico Jan 22 '13 at 23:28
  • I solved the error I write before, I was copying a non-copyable form in an assigment like this: `Form form_info = content.form_info;` and then called load() from it. Thanks again for your help. – nico Jan 23 '13 at 00:09
  • glad to be of any help even if I don't spotted the exact problem :) – CoffeDeveloper Jan 23 '13 at 01:30