开发者

$this->load->library('form_helper') equivalent in C++?

I am wondering if you were to write the following Codeigniter PHP code:

$this->load->library('form_validation');

In C++

would it be something like this

class CI {}; //class

CI this; //instance of class made ca开发者_运维问答lled this

this.load.library('form_validation'); 

This is purely academic and not for practical purposes.

As I am trying to make an equivelant to CI in C++ for fun

Thanks


No-- Loading a library in C++ is platform-specific and not very simple.

C++ is a very different language than PHP, and if you are unfamiliar with it, you should try a much simpler project first...


There is just so much wrong with this question.

C++ is a compiled language vs PHP which is interpreted.

In C++ one has to include references to libraries using the #include statement. This effectively implants the source of that file into the file being used.

The codeigniter example is loading its own library code since its a framework.

This could be accomplished in C++ by writing one's own framework and libraries.

Codeigniter is basically parsing the library at runtime to add functionality.

The same could be done by writing a server wrapper with functionality to import C++ code when passed a library argument.


$this->load->library('form_validation');

in this statement, $this is a keyword refering to the class you are currently in, meaning if you are in a method of class Foo, then $this refers to the the Foo object.

"->" is similar to a dot "." in c++, separating an object reference from its properties or methods, meaning if object $foo has a method named bar(), $foo->bar() would call that method.

"load" and "library" are both object and method names that are specific to the codeigniter controller base class, and are therfore meaningless in c++ unless you create them yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜