Content deleted Content added
Line 550:
A simple example of using C++ modules is as follows:
{{mono|
<syntaxhighlight lang="cpp">
export module myproject.
import std;
using String = std::string;
export namespace hello {▼
std::println("Hello world!");▼
class MyClass {
private:
int x;
String name;
public:
MyClass(int x, const String& name):
x{x}, name{name} {}
int getX() const noexcept {
return x;
}
void setX(int newX) noexcept {
x = newX;
};
String getName() const noexcept {
return name;
}
void setName(const String& newName) noexcept {
name = newName;
}
}
Line 565 ⟶ 587:
{{mono|Main.cpp}}
<syntaxhighlight lang="cpp">
import
import myproject.MyClass;
using myproject::MyClass;
int main() {
MyClass me(10, "MyName");
me.setX(15);
}
</syntaxhighlight>
|