I would like to ask how to create a module on c++ for v lang. For example
с++
int some_method() {
return 6
}
v
import my_c_module
my_c_module.some_method()
I will be grateful for any information
And can I call c++ class method in v lang?
I would like to ask how to create a module on c++ for v lang. For example
с++
int some_method() {
return 6
}
v
import my_c_module
my_c_module.some_method()
I will be grateful for any information
And can I call c++ class method in v lang?
In V every file in the root of a folder is part of the same module. Simple programs don't need to specify module name, in which case it defaults to 'main'.
V is a very modular language. Creating reusable modules is encouraged and is quite easy to do. To create a new module, create a directory with your module's name containing .v files with code:
cd ~/code/modules
mkdir mymodule
vim mymodule/myfile.v
Inside myfile.v
// myfile.v
module mymodule
// To export a function we have to use `pub`
pub fn say_hi() {
println('hello from mymodule!')
}
Now you can call your module
import mymodule
fn main() {
mymodule.say_hi()
}
You can create also your custom module, and here is the official docs