class function c++ code example
Example 1: c++ class method example
class Object {
public:
int var;
void setVar(int n) {
var = n;
}
int getNum() {
return var;
}
};
int main() {
Object obj;
obj.setVar(13);
std::cout << obj.getNum() << std::endl;
return 0;
}
Example 2: c++ classes
class SampleClass
{
int a;
public:
SampleClass(int v)
{
a=v;
}
int RetVal()
{
return a;
}
};
Example 3: C++ class
class Personnage
{
};
Example 4: class in c++
class Name {
private:
int data;
public:
Name() {
}
int id;
void fun1(int a) {
}
}